mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-18 01:36:08 +08:00
core&ui: add error & fix error notification (#464)
This commit is contained in:
1 parent
a2ea3812df
commit
534a634028
14 files changed
+123
-76
No files matched your search
@@ -2,7 +2,7 @@ import { escapeRegExp, pick } from 'lodash';
|
||||
import { FilterQuery, ObjectID } from 'mongodb';
|
||||
import type { Readable } from 'stream';
|
||||
import { streamToBuffer } from '@hydrooj/utils/lib/utils';
|
||||
import { ProblemNotFoundError, ValidationError } from '../error';
|
||||
import { FileUploadError, ProblemNotFoundError, ValidationError } from '../error';
|
||||
import type {
|
||||
Document, ProblemDict, ProblemStatusDoc, User,
|
||||
} from '../interface';
|
||||
@@ -245,7 +245,7 @@ export class ProblemModel {
|
||||
storage.put(`problem/${domainId}/${pid}/testdata/${name}`, f, operator),
|
||||
]);
|
||||
const meta = await storage.getMeta(`problem/${domainId}/${pid}/testdata/${name}`);
|
||||
if (!meta) throw new Error('Upload failed');
|
||||
if (!meta) throw new FileUploadError();
|
||||
const payload = { name, ...pick(meta, ['size', 'lastModified', 'etag']) };
|
||||
payload.lastModified ||= new Date();
|
||||
if (!fileinfo) await ProblemModel.push(domainId, pid, 'data', { _id: name, ...payload });
|
||||
|
||||
Reference in new issue
Block a user