浏览代码

feat(server): support rclone as storage backend (#2832)

cycneuramus 2 年之前
父节点
当前提交
296c77ac73
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      server/src/infra/repositories/filesystem.provider.ts

+ 5 - 1
server/src/infra/repositories/filesystem.provider.ts

@@ -19,7 +19,11 @@ export class FilesystemProvider implements IStorageRepository {
   }
 
   async moveFile(source: string, destination: string): Promise<void> {
-    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<boolean> {