MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / renameAdditionalFile

Method renameAdditionalFile

packages/hydrooj/src/model/problem.ts:351–365  ·  view source on GitHub ↗
(domainId: string, pid: number, file: string, newName: string, operator = 1)

Source from the content-addressed store, hash-verified

349 }
350
351 static async renameAdditionalFile(domainId: string, pid: number, file: string, newName: string, operator = 1) {
352 if (file === newName) return;
353 const [, sdoc] = await document.getSub(domainId, document.TYPE_PROBLEM, pid, 'additional_file', newName);
354 if (sdoc) await ProblemModel.delAdditionalFile(domainId, pid, newName);
355 const payload = { _id: newName, name: newName, lastModified: new Date() };
356 await Promise.all([
357 storage.rename(
358 `problem/${domainId}/${pid}/additional_file/${file}`,
359 `problem/${domainId}/${pid}/additional_file/${newName}`,
360 operator,
361 ),
362 document.setSub(domainId, document.TYPE_PROBLEM, pid, 'additional_file', file, payload),
363 ]);
364 await bus.emit('problem/renameAdditionalFile', domainId, pid, file, newName);
365 }
366
367 static async delAdditionalFile(domainId: string, pid: number, name: MaybeArray<string>, operator = 1) {
368 const names = (name instanceof Array) ? name : [name];

Callers 1

postRenameFilesMethod · 0.80

Calls 3

delAdditionalFileMethod · 0.80
renameMethod · 0.80
allMethod · 0.45

Tested by

no test coverage detected