Skip to content

Commit e85ead7

Browse files
committed
fix(backend:files): correct directory flag and ensure consistent file move operation in trash handling
1 parent e69a687 commit e85ead7

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

backend/src/applications/files/services/files-manager.service.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -427,14 +427,12 @@ export class FilesManager {
427427
// move the resource in db
428428
const trashFileDB: FileDBProps = { ...space.dbFile, inTrash: true }
429429
const dstTrashFileDB: FileDBProps = { ...trashFileDB, path: path.join(dirName(trashFileDB.path), fileName(dstTrash.path)) }
430-
this.filesQueries
431-
.moveFiles(trashFileDB, dstTrashFileDB, dstTrash.isDir)
432-
.catch((e: Error) => this.logger.error(`${this.delete.name} - ${e}`))
430+
await this.filesQueries.moveFiles(trashFileDB, dstTrashFileDB, dstTrash.isDir)
433431
}
434432
await moveFiles(space.realPath, trashFile, true)
435433
} else {
436-
this.logger.log(`Unable to find trash path for space - *${space.alias}* (${space.id}) : delete permanently : ${space.realPath}`)
437-
// todo: define a default trash for external paths
434+
// unsupported case: delete the file (this shouldn't happen)
435+
this.logger.error(`Unable to find trash path for space - *${space.alias}* (${space.id}) : delete permanently : ${space.realPath}`)
438436
forceDeleteInDB = true
439437
await removeFiles(space.realPath)
440438
}

backend/src/applications/files/utils/files.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ export async function uniqueDatedFilePath(rPath: string): Promise<{ isDir: boole
263263
} else {
264264
const extension = path.extname(rPath)
265265
const nameWithoutExtension = path.basename(rPath, extension)
266-
return { isDir: true, path: path.join(path.dirname(rPath), `${nameWithoutExtension}-${date}${extension}`) }
266+
return { isDir: false, path: path.join(path.dirname(rPath), `${nameWithoutExtension}-${date}${extension}`) }
267267
}
268268
}
269269

0 commit comments

Comments
 (0)