mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: remote delete file / Fix: broken Filesystem recycle in upload request
This commit is contained in:
@@ -265,7 +265,6 @@ func FileUploadStream(c *gin.Context) {
|
||||
c.JSON(200, serializer.Err(serializer.CodePolicyNotAllowed, err.Error(), err))
|
||||
return
|
||||
}
|
||||
defer fs.Recycle()
|
||||
|
||||
// 给文件系统分配钩子
|
||||
fs.Use("BeforeUpload", filesystem.HookValidateFile)
|
||||
|
||||
@@ -25,7 +25,6 @@ func SlaveUpload(c *gin.Context) {
|
||||
c.JSON(200, serializer.Err(serializer.CodePolicyNotAllowed, err.Error(), err))
|
||||
return
|
||||
}
|
||||
defer fs.Recycle()
|
||||
fs.Handler = local.Handler{}
|
||||
|
||||
// 从请求中取得上传策略
|
||||
@@ -115,3 +114,18 @@ func SlavePreview(c *gin.Context) {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
}
|
||||
}
|
||||
|
||||
// SlaveDelete 从机删除
|
||||
func SlaveDelete(c *gin.Context) {
|
||||
// 创建上下文
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
var service explorer.SlaveFilesService
|
||||
if err := c.ShouldBindJSON(&service); err == nil {
|
||||
res := service.Delete(ctx, c)
|
||||
c.JSON(200, res)
|
||||
} else {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ func InitSlaveRouter() *gin.Engine {
|
||||
v3.GET("download/:speed/:path/:name", controllers.SlaveDownload)
|
||||
// 预览 / 外链
|
||||
v3.GET("source/:speed/:path/:name", controllers.SlavePreview)
|
||||
// 删除文件
|
||||
v3.POST("delete", controllers.SlaveDelete)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user