mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-08 04:54:32 +00:00
add mediaDirectory config option to configure location of uploaded media
This commit is contained in:
parent
9e8e08eb57
commit
4291a3d648
7 changed files with 26 additions and 10 deletions
|
@ -297,6 +297,10 @@ proxyBypassHosts:
|
||||||
#proxySmtp: socks4://127.0.0.1:1080 # use SOCKS4
|
#proxySmtp: socks4://127.0.0.1:1080 # use SOCKS4
|
||||||
#proxySmtp: socks5://127.0.0.1:1080 # use SOCKS5
|
#proxySmtp: socks5://127.0.0.1:1080 # use SOCKS5
|
||||||
|
|
||||||
|
# Path to the directory that uploaded media will be saved to
|
||||||
|
# Defaults to a folder called "files" in the Sharkey directory
|
||||||
|
#mediaDirectory: /var/lib/sharkey
|
||||||
|
|
||||||
# Media Proxy
|
# Media Proxy
|
||||||
#mediaProxy: https://example.com/proxy
|
#mediaProxy: https://example.com/proxy
|
||||||
|
|
||||||
|
|
|
@ -260,6 +260,10 @@ proxyBypassHosts:
|
||||||
#proxySmtp: socks4://127.0.0.1:1080 # use SOCKS4
|
#proxySmtp: socks4://127.0.0.1:1080 # use SOCKS4
|
||||||
#proxySmtp: socks5://127.0.0.1:1080 # use SOCKS5
|
#proxySmtp: socks5://127.0.0.1:1080 # use SOCKS5
|
||||||
|
|
||||||
|
# Path to the directory that uploaded media will be saved to
|
||||||
|
# Defaults to a folder called "files" in the Sharkey directory
|
||||||
|
#mediaDirectory: /var/lib/sharkey
|
||||||
|
|
||||||
# Media Proxy
|
# Media Proxy
|
||||||
#mediaProxy: https://example.com/proxy
|
#mediaProxy: https://example.com/proxy
|
||||||
|
|
||||||
|
|
|
@ -351,6 +351,10 @@ proxyBypassHosts:
|
||||||
#proxySmtp: socks4://127.0.0.1:1080 # use SOCKS4
|
#proxySmtp: socks4://127.0.0.1:1080 # use SOCKS4
|
||||||
#proxySmtp: socks5://127.0.0.1:1080 # use SOCKS5
|
#proxySmtp: socks5://127.0.0.1:1080 # use SOCKS5
|
||||||
|
|
||||||
|
# Path to the directory that uploaded media will be saved to
|
||||||
|
# Defaults to a folder called "files" in the Sharkey directory
|
||||||
|
#mediaDirectory: /var/lib/sharkey
|
||||||
|
|
||||||
# Media Proxy
|
# Media Proxy
|
||||||
# Reference Implementation: https://github.com/misskey-dev/media-proxy
|
# Reference Implementation: https://github.com/misskey-dev/media-proxy
|
||||||
# * Deliver a common cache between instances
|
# * Deliver a common cache between instances
|
||||||
|
|
|
@ -354,6 +354,10 @@ proxyBypassHosts:
|
||||||
#proxySmtp: socks4://127.0.0.1:1080 # use SOCKS4
|
#proxySmtp: socks4://127.0.0.1:1080 # use SOCKS4
|
||||||
#proxySmtp: socks5://127.0.0.1:1080 # use SOCKS5
|
#proxySmtp: socks5://127.0.0.1:1080 # use SOCKS5
|
||||||
|
|
||||||
|
# Path to the directory that uploaded media will be saved to
|
||||||
|
# Defaults to a folder called "files" in the Sharkey directory
|
||||||
|
#mediaDirectory: /var/lib/sharkey
|
||||||
|
|
||||||
# Media Proxy
|
# Media Proxy
|
||||||
# Reference Implementation: https://github.com/misskey-dev/media-proxy
|
# Reference Implementation: https://github.com/misskey-dev/media-proxy
|
||||||
# * Deliver a common cache between instances
|
# * Deliver a common cache between instances
|
||||||
|
|
|
@ -199,6 +199,10 @@ proxyBypassHosts:
|
||||||
#proxySmtp: socks4://127.0.0.1:1080 # use SOCKS4
|
#proxySmtp: socks4://127.0.0.1:1080 # use SOCKS4
|
||||||
#proxySmtp: socks5://127.0.0.1:1080 # use SOCKS5
|
#proxySmtp: socks5://127.0.0.1:1080 # use SOCKS5
|
||||||
|
|
||||||
|
# Path to the directory that uploaded media will be saved to
|
||||||
|
# Defaults to a folder called "files" in the Sharkey directory
|
||||||
|
#mediaDirectory: /var/lib/sharkey
|
||||||
|
|
||||||
# Media Proxy
|
# Media Proxy
|
||||||
#mediaProxy: https://example.com/proxy
|
#mediaProxy: https://example.com/proxy
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,7 @@ type Source = {
|
||||||
deliverJobMaxAttempts?: number;
|
deliverJobMaxAttempts?: number;
|
||||||
inboxJobMaxAttempts?: number;
|
inboxJobMaxAttempts?: number;
|
||||||
|
|
||||||
|
mediaDirectory?: string;
|
||||||
mediaProxy?: string;
|
mediaProxy?: string;
|
||||||
proxyRemoteFiles?: boolean;
|
proxyRemoteFiles?: boolean;
|
||||||
videoThumbnailGenerator?: string;
|
videoThumbnailGenerator?: string;
|
||||||
|
@ -297,6 +298,7 @@ export type Config = {
|
||||||
frontendManifestExists: boolean;
|
frontendManifestExists: boolean;
|
||||||
frontendEmbedEntry: string;
|
frontendEmbedEntry: string;
|
||||||
frontendEmbedManifestExists: boolean;
|
frontendEmbedManifestExists: boolean;
|
||||||
|
mediaDirectory: string;
|
||||||
mediaProxy: string;
|
mediaProxy: string;
|
||||||
externalMediaProxyEnabled: boolean;
|
externalMediaProxyEnabled: boolean;
|
||||||
videoThumbnailGenerator: string | null;
|
videoThumbnailGenerator: string | null;
|
||||||
|
@ -463,6 +465,7 @@ export function loadConfig(): Config {
|
||||||
signToActivityPubGet: config.signToActivityPubGet ?? true,
|
signToActivityPubGet: config.signToActivityPubGet ?? true,
|
||||||
attachLdSignatureForRelays: config.attachLdSignatureForRelays ?? true,
|
attachLdSignatureForRelays: config.attachLdSignatureForRelays ?? true,
|
||||||
checkActivityPubGetSignature: config.checkActivityPubGetSignature,
|
checkActivityPubGetSignature: config.checkActivityPubGetSignature,
|
||||||
|
mediaDirectory: config.mediaDirectory ?? resolve(_dirname, '../../../files'),
|
||||||
mediaProxy: externalMediaProxy ?? internalMediaProxy,
|
mediaProxy: externalMediaProxy ?? internalMediaProxy,
|
||||||
externalMediaProxyEnabled: externalMediaProxy !== null && externalMediaProxy !== internalMediaProxy,
|
externalMediaProxyEnabled: externalMediaProxy !== null && externalMediaProxy !== internalMediaProxy,
|
||||||
videoThumbnailGenerator: config.videoThumbnailGenerator ?
|
videoThumbnailGenerator: config.videoThumbnailGenerator ?
|
||||||
|
@ -638,7 +641,7 @@ function applyEnvOverrides(config: Source) {
|
||||||
_apply_top(['sentryForFrontend', 'vueIntegration', 'tracingOptions', 'timeout']);
|
_apply_top(['sentryForFrontend', 'vueIntegration', 'tracingOptions', 'timeout']);
|
||||||
_apply_top(['sentryForFrontend', 'browserTracingIntegration', 'routeLabel']);
|
_apply_top(['sentryForFrontend', 'browserTracingIntegration', 'routeLabel']);
|
||||||
_apply_top([['clusterLimit', 'deliverJobConcurrency', 'inboxJobConcurrency', 'relashionshipJobConcurrency', 'deliverJobPerSec', 'inboxJobPerSec', 'relashionshipJobPerSec', 'deliverJobMaxAttempts', 'inboxJobMaxAttempts']]);
|
_apply_top([['clusterLimit', 'deliverJobConcurrency', 'inboxJobConcurrency', 'relashionshipJobConcurrency', 'deliverJobPerSec', 'inboxJobPerSec', 'relashionshipJobPerSec', 'deliverJobMaxAttempts', 'inboxJobMaxAttempts']]);
|
||||||
_apply_top([['outgoingAddress', 'outgoingAddressFamily', 'proxy', 'proxySmtp', 'mediaProxy', 'proxyRemoteFiles', 'videoThumbnailGenerator']]);
|
_apply_top([['outgoingAddress', 'outgoingAddressFamily', 'proxy', 'proxySmtp', 'mediaDirectory', 'mediaProxy', 'proxyRemoteFiles', 'videoThumbnailGenerator']]);
|
||||||
_apply_top([['maxFileSize', 'maxNoteLength', 'maxRemoteNoteLength', 'maxAltTextLength', 'maxRemoteAltTextLength', 'pidFile', 'filePermissionBits']]);
|
_apply_top([['maxFileSize', 'maxNoteLength', 'maxRemoteNoteLength', 'maxAltTextLength', 'maxRemoteAltTextLength', 'pidFile', 'filePermissionBits']]);
|
||||||
_apply_top(['import', ['downloadTimeout', 'maxFileSize']]);
|
_apply_top(['import', ['downloadTimeout', 'maxFileSize']]);
|
||||||
_apply_top([['signToActivityPubGet', 'checkActivityPubGetSignature', 'setupPassword', 'disallowExternalApRedirect']]);
|
_apply_top([['signToActivityPubGet', 'checkActivityPubGetSignature', 'setupPassword', 'disallowExternalApRedirect']]);
|
||||||
|
|
|
@ -6,18 +6,11 @@
|
||||||
import * as fs from 'node:fs';
|
import * as fs from 'node:fs';
|
||||||
import { copyFile, unlink, writeFile, chmod } from 'node:fs/promises';
|
import { copyFile, unlink, writeFile, chmod } from 'node:fs/promises';
|
||||||
import * as Path from 'node:path';
|
import * as Path from 'node:path';
|
||||||
import { fileURLToPath } from 'node:url';
|
|
||||||
import { dirname } from 'node:path';
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import type { Config } from '@/config.js';
|
import type { Config } from '@/config.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
|
|
||||||
const _filename = fileURLToPath(import.meta.url);
|
|
||||||
const _dirname = dirname(_filename);
|
|
||||||
|
|
||||||
const path = Path.resolve(_dirname, '../../../../files');
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class InternalStorageService {
|
export class InternalStorageService {
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -25,12 +18,12 @@ export class InternalStorageService {
|
||||||
private config: Config,
|
private config: Config,
|
||||||
) {
|
) {
|
||||||
// No one should erase the working directory *while the server is running*.
|
// No one should erase the working directory *while the server is running*.
|
||||||
fs.mkdirSync(path, { recursive: true });
|
fs.mkdirSync(this.config.mediaDirectory, { recursive: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public resolvePath(key: string) {
|
public resolvePath(key: string) {
|
||||||
return Path.resolve(path, key);
|
return Path.resolve(this.config.mediaDirectory, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
|
Loading…
Add table
Reference in a new issue