mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
feat(dashboard): unlink file while not deleting its physical source (#789)
This commit is contained in:
@@ -19,8 +19,9 @@ type FileService struct {
|
||||
|
||||
// FileBatchService 文件批量操作服务
|
||||
type FileBatchService struct {
|
||||
ID []uint `json:"id" binding:"min=1"`
|
||||
Force bool `json:"force"`
|
||||
ID []uint `json:"id" binding:"min=1"`
|
||||
Force bool `json:"force"`
|
||||
UnlinkOnly bool `json:"unlink"`
|
||||
}
|
||||
|
||||
// ListFolderService 列目录结构
|
||||
@@ -128,7 +129,7 @@ func (service *FileBatchService) Delete(c *gin.Context) serializer.Response {
|
||||
}
|
||||
|
||||
// 执行删除
|
||||
fs.Delete(context.Background(), []uint{}, ids, service.Force)
|
||||
fs.Delete(context.Background(), []uint{}, ids, service.Force, service.UnlinkOnly)
|
||||
fs.Recycle()
|
||||
}
|
||||
}(userFile)
|
||||
|
||||
@@ -66,7 +66,7 @@ func (service *UserBatchService) Delete() serializer.Response {
|
||||
if err != nil {
|
||||
return serializer.Err(serializer.CodeInternalSetting, "User's root folder not exist", err)
|
||||
}
|
||||
fs.Delete(context.Background(), []uint{root.ID}, []uint{}, false)
|
||||
fs.Delete(context.Background(), []uint{root.ID}, []uint{}, false, false)
|
||||
|
||||
// 删除相关任务
|
||||
model.DB.Where("user_id = ?", uid).Delete(&model.Download{})
|
||||
|
||||
@@ -274,7 +274,7 @@ func (service *ItemIDService) Delete(ctx context.Context, c *gin.Context) serial
|
||||
|
||||
// 删除对象
|
||||
items := service.Raw()
|
||||
err = fs.Delete(ctx, items.Dirs, items.Items, false)
|
||||
err = fs.Delete(ctx, items.Dirs, items.Items, false, false)
|
||||
if err != nil {
|
||||
return serializer.Err(serializer.CodeNotSet, err.Error(), err)
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ func (service *UploadSessionService) Delete(ctx context.Context, c *gin.Context)
|
||||
}
|
||||
|
||||
// 删除文件
|
||||
if err := fs.Delete(ctx, []uint{}, []uint{file.ID}, false); err != nil {
|
||||
if err := fs.Delete(ctx, []uint{}, []uint{file.ID}, false, false); err != nil {
|
||||
return serializer.Err(serializer.CodeInternalSetting, "Failed to delete upload session", err)
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ func DeleteAllUploadSession(ctx context.Context, c *gin.Context) serializer.Resp
|
||||
}
|
||||
|
||||
// 删除文件
|
||||
if err := fs.Delete(ctx, []uint{}, fileIDs, false); err != nil {
|
||||
if err := fs.Delete(ctx, []uint{}, fileIDs, false, false); err != nil {
|
||||
return serializer.Err(serializer.CodeInternalSetting, "Failed to cleanup upload session", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user