core: trim filename spaces

pull/525/head
undefined 2 years ago
parent 9cd7c5cfab
commit 26a39501c2
No known key found for this signature in database

@ -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),

@ -37,6 +37,7 @@ export { Collections } from './service/db';
// export { Collections } from './interface';
export { Service, Context } from './context';
export { buildContent } from './lib/content';
export { default as rating } from './lib/rating';
export { default as avatar } from './lib/avatar';
export { default as rank } from './lib/rank';
export { default as paginate } from './lib/paginate';

Loading…
Cancel
Save