diff --git a/models/group.go b/models/group.go index 490fc38..7b8930c 100644 --- a/models/group.go +++ b/models/group.go @@ -34,6 +34,7 @@ type GroupOption struct { SourceBatchSize int `json:"source_batch,omitempty"` RedirectedSource bool `json:"redirected_source,omitempty"` Aria2BatchSize int `json:"aria2_batch,omitempty"` + AdvanceDelete bool `json:"advance_delete,omitempty"` } // GetGroupByID 用ID获取用户组 diff --git a/models/migration.go b/models/migration.go index 17a08ce..fad6a76 100644 --- a/models/migration.go +++ b/models/migration.go @@ -111,6 +111,7 @@ func addDefaultGroups() { SourceBatchSize: 1000, Aria2BatchSize: 50, RedirectedSource: true, + AdvanceDelete: true, }, } if err := DB.Create(&defaultAdminGroup).Error; err != nil { diff --git a/pkg/serializer/user.go b/pkg/serializer/user.go index 68e9940..45b703e 100644 --- a/pkg/serializer/user.go +++ b/pkg/serializer/user.go @@ -41,6 +41,7 @@ type group struct { CompressEnabled bool `json:"compress"` WebDAVEnabled bool `json:"webdav"` SourceBatchSize int `json:"sourceBatch"` + AdvanceDelete bool `json:"advanceDelete"` } type tag struct { @@ -100,6 +101,7 @@ func BuildUser(user model.User) User { CompressEnabled: user.Group.OptionsSerialized.ArchiveTask, WebDAVEnabled: user.Group.WebDAVEnabled, SourceBatchSize: user.Group.OptionsSerialized.SourceBatchSize, + AdvanceDelete: user.Group.OptionsSerialized.AdvanceDelete, }, Tags: buildTagRes(tags), } diff --git a/service/explorer/objects.go b/service/explorer/objects.go index 2aacefd..1c3c45a 100644 --- a/service/explorer/objects.go +++ b/service/explorer/objects.go @@ -41,9 +41,11 @@ type ItemService struct { // ItemIDService 处理多文件/目录相关服务,字段值为HashID,可通过Raw()方法获取原始ID type ItemIDService struct { - Items []string `json:"items"` - Dirs []string `json:"dirs"` - Source *ItemService + Items []string `json:"items"` + Dirs []string `json:"dirs"` + Source *ItemService + Force bool `json:"force"` + UnlinkOnly bool `json:"unlink"` } // ItemCompressService 文件压缩任务服务 @@ -272,9 +274,15 @@ func (service *ItemIDService) Delete(ctx context.Context, c *gin.Context) serial } defer fs.Recycle() + force, unlink := false, false + if fs.User.Group.OptionsSerialized.AdvanceDelete { + force = service.Force + unlink = service.UnlinkOnly + } + // 删除对象 items := service.Raw() - err = fs.Delete(ctx, items.Dirs, items.Items, false, false) + err = fs.Delete(ctx, items.Dirs, items.Items, force, unlink) if err != nil { return serializer.Err(serializer.CodeNotSet, err.Error(), err) }