mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-18 09:36:08 +08:00
core: fix addAdditionalFile
This commit is contained in:
1 parent
250ae863d0
commit
3034f5ec79
1 file changed
+2
-4
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
escapeRegExp, pick,
|
||||
} from 'lodash';
|
||||
import { escapeRegExp, pick } from 'lodash';
|
||||
import { FilterQuery, ObjectID } from 'mongodb';
|
||||
import type { Readable } from 'stream';
|
||||
import { streamToBuffer } from '@hydrooj/utils/lib/utils';
|
||||
@@ -267,7 +265,7 @@ export class ProblemModel {
|
||||
static async addAdditionalFile(domainId: string, pid: number, name: string, f: Readable | Buffer | string, skipUpload = false) {
|
||||
const [[, fileinfo]] = await Promise.all([
|
||||
document.getSub(domainId, document.TYPE_PROBLEM, pid, 'additional_file', name),
|
||||
skipUpload || storage.put(`problem/${domainId}/${pid}/additional_file/${name}`, f),
|
||||
skipUpload ? '' : storage.put(`problem/${domainId}/${pid}/additional_file/${name}`, f),
|
||||
]);
|
||||
const meta = await storage.getMeta(`problem/${domainId}/${pid}/additional_file/${name}`);
|
||||
const payload = { name, ...pick(meta, ['size', 'lastModified', 'etag']) };
|
||||
|
||||
Reference in new issue
Block a user