core: trim filename spaces

This commit is contained in:
undefined committed 2023-03-02 11:17:17 +08:00
1 parent 9cd7c5cfab
commit 26a39501c2
2 files changed
+3

No files matched your search

+2
View File
@@ -239,6 +239,7 @@ export class ProblemModel {
}
static async addTestdata(domainId: string, pid: number, name: string, f: Readable | Buffer | string, operator = 1) {
name = name.trim();
if (!name) throw new ValidationError('name');
const [[, fileinfo]] = await Promise.all([
document.getSub(domainId, document.TYPE_PROBLEM, pid, 'data', name),
@@ -266,6 +267,7 @@ export class ProblemModel {
domainId: string, pid: number, name: string,
f: Readable | Buffer | string, operator = 1, skipUpload = false,
) {
name = name.trim();
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, operator),