replace String.random with randomstring

This commit is contained in:
undefined committed 2025-06-30 16:24:35 +08:00
1 parent b18cce3f66
commit 5d7f5fef38
22 files changed
+64 -48

No files matched your search

+2 -2
View File
@@ -10,7 +10,7 @@ import { nanoid } from 'nanoid';
import sanitize from 'sanitize-filename';
import Schema from 'schemastery';
import parser from '@hydrooj/utils/lib/search';
import { sortFiles, streamToBuffer } from '@hydrooj/utils/lib/utils';
import { randomstring, sortFiles, streamToBuffer } from '@hydrooj/utils/lib/utils';
import type { Context } from '../context';
import {
BadRequestError, ContestNotAttendedError, ContestNotEndedError, ContestNotFoundError, ContestNotLiveError,
@@ -709,7 +709,7 @@ export class ProblemFilesHandler extends ProblemDetailHandler {
async postUploadFile(domainId: string, filename: string, type = 'testdata') {
const file = this.request.files.file;
if (!file) throw new ValidationError('file');
filename ||= file.originalFilename || String.random(16);
filename ||= file.originalFilename || randomstring(16);
const files = [];
if (filename.endsWith('.zip') && type === 'testdata') {
const zip = new ZipReader(Readable.toWeb(createReadStream(file.filepath)));