mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-24 02:36:43 -06:00
allow setting separate timeout / max size for imports
This commit is contained in:
parent
edd83acaab
commit
59aa6b1509
4 changed files with 26 additions and 4 deletions
|
@ -225,3 +225,9 @@ signToActivityPubGet: true
|
|||
|
||||
# Upload or download file size limits (bytes)
|
||||
#maxFileSize: 262144000
|
||||
|
||||
|
||||
# timeout and maximum size for imports (e.g. note imports)
|
||||
#import:
|
||||
# downloadTimeout: 30
|
||||
# maxFileSize: 262144000
|
||||
|
|
|
@ -327,3 +327,9 @@ signToActivityPubGet: true
|
|||
|
||||
# PID File of master process
|
||||
#pidFile: /tmp/misskey.pid
|
||||
|
||||
|
||||
# timeout and maximum size for imports (e.g. note imports)
|
||||
#import:
|
||||
# downloadTimeout: 30
|
||||
# maxFileSize: 262144000
|
||||
|
|
|
@ -101,6 +101,11 @@ type Source = {
|
|||
deactivateAntennaThreshold?: number;
|
||||
pidFile: string;
|
||||
avatarDecorationAllowedHosts: string[] | undefined;
|
||||
|
||||
import?: {
|
||||
downloadTimeout: number;
|
||||
maxFileSize: number;
|
||||
};
|
||||
};
|
||||
|
||||
export type Config = {
|
||||
|
@ -186,6 +191,10 @@ export type Config = {
|
|||
deactivateAntennaThreshold: number;
|
||||
pidFile: string;
|
||||
avatarDecorationAllowedHosts: string[] | undefined;
|
||||
import: {
|
||||
downloadTimeout: number;
|
||||
maxFileSize: number;
|
||||
} | undefined;
|
||||
};
|
||||
|
||||
const _filename = fileURLToPath(import.meta.url);
|
||||
|
@ -299,6 +308,7 @@ export function loadConfig(): Config {
|
|||
deactivateAntennaThreshold: config.deactivateAntennaThreshold ?? (1000 * 60 * 60 * 24 * 7),
|
||||
pidFile: config.pidFile,
|
||||
avatarDecorationAllowedHosts: config.avatarDecorationAllowedHosts,
|
||||
import: config.import,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -35,14 +35,14 @@ export class DownloadService {
|
|||
}
|
||||
|
||||
@bindThis
|
||||
public async downloadUrl(url: string, path: string): Promise<{
|
||||
public async downloadUrl(url: string, path: string, options: { timeout?: number, operationTimeout?: number, maxSize?: number} = {} ): Promise<{
|
||||
filename: string;
|
||||
}> {
|
||||
this.logger.info(`Downloading ${chalk.cyan(url)} to ${chalk.cyanBright(path)} ...`);
|
||||
|
||||
const timeout = 30 * 1000;
|
||||
const operationTimeout = 60 * 1000;
|
||||
const maxSize = this.config.maxFileSize;
|
||||
const timeout = options.timeout ?? 30 * 1000;
|
||||
const operationTimeout = options.operationTimeout ?? 60 * 1000;
|
||||
const maxSize = options.maxSize ?? this.config.maxFileSize ?? 262144000;
|
||||
|
||||
const urlObj = new URL(url);
|
||||
let filename = urlObj.pathname.split('/').pop() ?? 'untitled';
|
||||
|
|
Loading…
Reference in a new issue