feat: clear cache after change
This commit is contained in:
@ -41,6 +41,7 @@ func FsMkdir(c *gin.Context) {
|
||||
common.ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
fs.ClearCache(stdpath.Dir(req.Path))
|
||||
common.SuccessResp(c)
|
||||
}
|
||||
|
||||
@ -81,6 +82,8 @@ func FsMove(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
}
|
||||
fs.ClearCache(req.SrcDir)
|
||||
fs.ClearCache(req.DstDir)
|
||||
common.SuccessResp(c)
|
||||
}
|
||||
|
||||
@ -112,6 +115,9 @@ func FsCopy(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if len(req.Names) != len(addedTask) {
|
||||
fs.ClearCache(req.DstDir)
|
||||
}
|
||||
if len(addedTask) > 0 {
|
||||
common.SuccessResp(c, fmt.Sprintf("Added %d tasks", len(addedTask)))
|
||||
} else {
|
||||
@ -140,11 +146,12 @@ func FsRename(c *gin.Context) {
|
||||
common.ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
fs.ClearCache(stdpath.Dir(req.Path))
|
||||
common.SuccessResp(c)
|
||||
}
|
||||
|
||||
type RemoveReq struct {
|
||||
Path string `json:"path"`
|
||||
Dir string `json:"dir"`
|
||||
Names []string `json:"names"`
|
||||
}
|
||||
|
||||
@ -163,14 +170,15 @@ func FsRemove(c *gin.Context) {
|
||||
common.ErrorResp(c, errs.PermissionDenied, 403)
|
||||
return
|
||||
}
|
||||
req.Path = stdpath.Join(user.BasePath, req.Path)
|
||||
req.Dir = stdpath.Join(user.BasePath, req.Dir)
|
||||
for _, name := range req.Names {
|
||||
err := fs.Remove(c, stdpath.Join(req.Path, name))
|
||||
err := fs.Remove(c, stdpath.Join(req.Dir, name))
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
}
|
||||
fs.ClearCache(req.Dir)
|
||||
common.SuccessResp(c)
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,8 @@ func moveFiles(ctx context.Context, src, dst string, overwrite bool) (status int
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
fs.ClearCache(path.Dir(src))
|
||||
fs.ClearCache(path.Dir(dst))
|
||||
// TODO if there are no files copy, should return 204
|
||||
return http.StatusCreated, nil
|
||||
}
|
||||
@ -43,6 +45,7 @@ func copyFiles(ctx context.Context, src, dst string, overwrite bool) (status int
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
fs.ClearCache(path.Dir(dst))
|
||||
// TODO if there are no files copy, should return 204
|
||||
return http.StatusCreated, nil
|
||||
}
|
||||
|
@ -267,6 +267,7 @@ func (h *Handler) handleDelete(w http.ResponseWriter, r *http.Request) (status i
|
||||
if err := fs.Remove(ctx, reqPath); err != nil {
|
||||
return http.StatusMethodNotAllowed, err
|
||||
}
|
||||
fs.ClearCache(path.Dir(reqPath))
|
||||
return http.StatusNoContent, nil
|
||||
}
|
||||
|
||||
@ -311,6 +312,7 @@ func (h *Handler) handlePut(w http.ResponseWriter, r *http.Request) (status int,
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
w.Header().Set("ETag", etag)
|
||||
fs.ClearCache(path.Dir(reqPath))
|
||||
return http.StatusCreated, nil
|
||||
}
|
||||
|
||||
@ -338,6 +340,7 @@ func (h *Handler) handleMkcol(w http.ResponseWriter, r *http.Request) (status in
|
||||
}
|
||||
return http.StatusMethodNotAllowed, err
|
||||
}
|
||||
fs.ClearCache(path.Dir(reqPath))
|
||||
return http.StatusCreated, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user