mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: problem.import: add delSource option
This commit is contained in:
3 files changed
+28
-13
No files matched your search
@@ -19,7 +19,12 @@ class ProblemImportHydroHandler extends Handler {
|
||||
if (preferredPrefix && !/^[a-zA-Z]+$/.test(preferredPrefix)) throw new ValidationError('preferredPrefix');
|
||||
const promise = problem.import(
|
||||
domainId, this.request.files.file.filepath,
|
||||
{ preferredPrefix, progress: this.progress.bind(this), operator: keepUser ? null : this.user._id },
|
||||
{
|
||||
preferredPrefix,
|
||||
progress: this.progress.bind(this),
|
||||
operator: keepUser ? null : this.user._id,
|
||||
delSource: true,
|
||||
},
|
||||
).catch((e) => MessageModel.send(1, this.user._id, `Import failed: ${e.message}\n${e.stack}`));
|
||||
let resolved = false;
|
||||
await Promise.race([
|
||||
|
||||
@@ -729,7 +729,7 @@ export class ProblemFilesHandler extends ProblemDetailHandler {
|
||||
if ((this.pdoc.data?.length || 0)
|
||||
+ (this.pdoc.additional_file?.length || 0)
|
||||
+ files.length
|
||||
>= system.get('limit.problem_files_max')) {
|
||||
>= this.ctx.setting.get('limit.problem_files_max')) {
|
||||
throw new FileLimitExceededError('count');
|
||||
}
|
||||
const size = Math.sum(
|
||||
@@ -737,7 +737,7 @@ export class ProblemFilesHandler extends ProblemDetailHandler {
|
||||
(this.pdoc.additional_file || []).map((i) => i.size),
|
||||
files.map((i) => i.size),
|
||||
);
|
||||
if (size >= system.get('limit.problem_files_max_size')) {
|
||||
if (size >= this.ctx.setting.get('limit.problem_files_max_size')) {
|
||||
throw new FileLimitExceededError('size');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user