(domainId: string, pid: number, file: string, newName: string, operator = 1)
| 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]; |
no test coverage detected