From 296c77ac73df1e16c85701d5f7758892ccd41dad Mon Sep 17 00:00:00 2001 From: cycneuramus <56681631+cycneuramus@users.noreply.github.com> Date: Mon, 19 Jun 2023 18:58:10 +0200 Subject: [PATCH] feat(server): support rclone as storage backend (#2832) --- server/src/infra/repositories/filesystem.provider.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/src/infra/repositories/filesystem.provider.ts b/server/src/infra/repositories/filesystem.provider.ts index e3c8c4d615..dcb151b4d8 100644 --- a/server/src/infra/repositories/filesystem.provider.ts +++ b/server/src/infra/repositories/filesystem.provider.ts @@ -19,7 +19,11 @@ export class FilesystemProvider implements IStorageRepository { } async moveFile(source: string, destination: string): Promise { - await moveFile(source, destination, { mkdirp: true, clobber: false }); + if (await this.checkFileExists(destination)) { + throw new Error(`Destination file already exists: ${destination}`); + } + + await moveFile(source, destination, { mkdirp: true, clobber: true }); } async checkFileExists(filepath: string, mode = constants.F_OK): Promise {