mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: fix cli usage
This commit is contained in:
1 parent
895d50530a
commit
5f7dae0111
2 files changed
+22
-23
No files matched your search
@@ -6,7 +6,7 @@ import fs from 'fs-extra';
|
|||||||
import { ObjectID } from 'mongodb';
|
import { ObjectID } from 'mongodb';
|
||||||
import db from '../service/db';
|
import db from '../service/db';
|
||||||
import {
|
import {
|
||||||
lib, model, script, service,
|
addon, lib, model, script, service, setting,
|
||||||
} from './common';
|
} from './common';
|
||||||
|
|
||||||
const argv = cac().parse();
|
const argv = cac().parse();
|
||||||
@@ -87,15 +87,20 @@ export async function load(ctx) {
|
|||||||
require('../error');
|
require('../error');
|
||||||
await db.start();
|
await db.start();
|
||||||
await require('../settings').loadConfig();
|
await require('../settings').loadConfig();
|
||||||
const storage = require('../service/storage');
|
await require('../model/system').runConfig();
|
||||||
await storage.loadStorageService();
|
await require('../service/storage').loadStorageService();
|
||||||
|
await ctx.root.start();
|
||||||
require('../lib/index');
|
require('../lib/index');
|
||||||
await lib(pending, fail, ctx);
|
await Promise.all([
|
||||||
const systemModel = require('../model/system');
|
lib(pending, fail, ctx),
|
||||||
await systemModel.runConfig();
|
service(pending, fail, ctx),
|
||||||
await service(pending, fail, ctx);
|
]);
|
||||||
require('../model/index');
|
require('../model/index');
|
||||||
await model(pending, fail, ctx);
|
await Promise.all([
|
||||||
|
model(pending, fail, ctx),
|
||||||
|
setting(pending, fail, require('../model/setting')),
|
||||||
|
]);
|
||||||
|
await addon(pending, fail, ctx);
|
||||||
const scriptDir = path.resolve(__dirname, '..', 'script');
|
const scriptDir = path.resolve(__dirname, '..', 'script');
|
||||||
for (const h of await fs.readdir(scriptDir)) {
|
for (const h of await fs.readdir(scriptDir)) {
|
||||||
ctx.loader.reloadPlugin(ctx, path.resolve(scriptDir, h), {}, `hydrooj/script/${h.split('.')[0]}`);
|
ctx.loader.reloadPlugin(ctx, path.resolve(scriptDir, h), {}, `hydrooj/script/${h.split('.')[0]}`);
|
||||||
|
|||||||
@@ -186,21 +186,15 @@ class RemoteStorageService {
|
|||||||
|
|
||||||
async signDownloadLink(target: string, filename?: string, noExpire = false, useAlternativeEndpointFor?: 'user' | 'judge'): Promise<string> {
|
async signDownloadLink(target: string, filename?: string, noExpire = false, useAlternativeEndpointFor?: 'user' | 'judge'): Promise<string> {
|
||||||
if (target.includes('..') || target.includes('//')) throw new Error('Invalid path');
|
if (target.includes('..') || target.includes('//')) throw new Error('Invalid path');
|
||||||
try {
|
const url = await getSignedUrl(this.client, new GetObjectCommand({
|
||||||
const url = await getSignedUrl(this.client, new GetObjectCommand({
|
Bucket: this.opts.bucket,
|
||||||
Bucket: this.opts.bucket,
|
Key: target,
|
||||||
Key: target,
|
ResponseContentDisposition: filename ? `attachment; filename="${encodeRFC5987ValueChars(filename)}"` : '',
|
||||||
ResponseContentDisposition: filename ? `attachment; filename="${encodeRFC5987ValueChars(filename)}"` : '',
|
}), {
|
||||||
}), {
|
expiresIn: noExpire ? 24 * 60 * 60 * 7 : 10 * 60,
|
||||||
expiresIn: noExpire ? 24 * 60 * 60 * 7 : 10 * 60,
|
});
|
||||||
});
|
if (useAlternativeEndpointFor) return this.replaceWithAlternativeUrlFor[useAlternativeEndpointFor](url);
|
||||||
console.log(url);
|
return url;
|
||||||
if (useAlternativeEndpointFor) return this.replaceWithAlternativeUrlFor[useAlternativeEndpointFor](url);
|
|
||||||
return url;
|
|
||||||
} catch (e) {
|
|
||||||
e.stack = new Error().stack;
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async signUpload(target: string, size: number) {
|
async signUpload(target: string, size: number) {
|
||||||
|
|||||||
Reference in new issue
Block a user