( userId: string, oldPath: string, newPath: string, oldName: string, newName: string, )
| 686 | } |
| 687 | |
| 688 | async function renameDirectoryOrFile( |
| 689 | userId: string, |
| 690 | oldPath: string, |
| 691 | newPath: string, |
| 692 | oldName: string, |
| 693 | newName: string, |
| 694 | ): Promise<boolean> { |
| 695 | await ensureUserPathIsValidAndSecurelyAccessible(userId, join(oldPath, oldName)); |
| 696 | await ensureUserPathIsValidAndSecurelyAccessible(userId, join(newPath, newName)); |
| 697 | |
| 698 | const oldRootPath = join(await AppConfig.getFilesRootPath(), userId, oldPath); |
| 699 | const newRootPath = join(await AppConfig.getFilesRootPath(), userId, newPath); |
| 700 | |
| 701 | try { |
| 702 | await Deno.rename(join(oldRootPath, oldName), join(newRootPath, newName)); |
| 703 | } catch (error) { |
| 704 | console.error(error); |
| 705 | return false; |
| 706 | } |
| 707 | |
| 708 | return true; |
| 709 | } |
| 710 | |
| 711 | async function deleteDirectoryOrFile(userId: string, path: string, name: string): Promise<boolean> { |
| 712 | await ensureUserPathIsValidAndSecurelyAccessible(userId, join(path, name)); |
no test coverage detected