feat(dashboard): unlink file while not deleting its physical source (#789)

This commit is contained in:
Aaron Liu
2023-02-07 20:07:05 +08:00
parent 2a1e82aede
commit 1c1cd9b342
9 changed files with 28 additions and 22 deletions

View File

@@ -120,8 +120,9 @@ func (fs *FileSystem) Move(ctx context.Context, dirs, files []uint, src, dst str
return err
}
// Delete 递归删除对象, force 为 true 时强制删除文件记录,忽略物理删除是否成功
func (fs *FileSystem) Delete(ctx context.Context, dirs, files []uint, force bool) error {
// Delete 递归删除对象, force 为 true 时强制删除文件记录,忽略物理删除是否成功;
// unlink 为 true 时只删除虚拟文件系统的文件记录,不删除物理文件。
func (fs *FileSystem) Delete(ctx context.Context, dirs, files []uint, force, unlink bool) error {
// 已删除的文件ID
var deletedFiles = make([]*model.File, 0, len(fs.FileTarget))
// 删除失败的文件的父目录ID
@@ -155,7 +156,10 @@ func (fs *FileSystem) Delete(ctx context.Context, dirs, files []uint, force bool
policyGroup := fs.GroupFileByPolicy(ctx, filesToBeDelete)
// 按照存储策略分组删除对象
failed := fs.deleteGroupedFile(ctx, policyGroup)
failed := make(map[uint][]string)
if !unlink {
failed = fs.deleteGroupedFile(ctx, policyGroup)
}
// 整理删除结果
for i := 0; i < len(fs.FileTarget); i++ {