perf(alias): disabled log on fs call (close #4054)
This commit is contained in:
@ -21,7 +21,7 @@ import (
|
||||
func Down(c *gin.Context) {
|
||||
rawPath := c.MustGet("path").(string)
|
||||
filename := stdpath.Base(rawPath)
|
||||
storage, err := fs.GetStorage(rawPath)
|
||||
storage, err := fs.GetStorage(rawPath, &fs.GetStoragesArgs{})
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 500)
|
||||
return
|
||||
@ -65,7 +65,7 @@ func Down(c *gin.Context) {
|
||||
func Proxy(c *gin.Context) {
|
||||
rawPath := c.MustGet("path").(string)
|
||||
filename := stdpath.Base(rawPath)
|
||||
storage, err := fs.GetStorage(rawPath)
|
||||
storage, err := fs.GetStorage(rawPath, &fs.GetStoragesArgs{})
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 500)
|
||||
return
|
||||
|
@ -133,7 +133,7 @@ func FsRecursiveMove(c *gin.Context) {
|
||||
}
|
||||
c.Set("meta", meta)
|
||||
|
||||
rootFiles, err := fs.List(c, srcDir, false)
|
||||
rootFiles, err := fs.List(c, srcDir, &fs.ListArgs{})
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 500)
|
||||
return
|
||||
@ -154,7 +154,7 @@ func FsRecursiveMove(c *gin.Context) {
|
||||
if movingFile.IsDir() {
|
||||
// directory, recursive move
|
||||
subFilePath := movingFilePath
|
||||
subFiles, err := fs.List(c, subFilePath, true)
|
||||
subFiles, err := fs.List(c, subFilePath, &fs.ListArgs{Refresh: true})
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 500)
|
||||
return
|
||||
@ -293,7 +293,7 @@ func FsRegexRename(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
files, err := fs.List(c, reqPath, false)
|
||||
files, err := fs.List(c, reqPath, &fs.ListArgs{})
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 500)
|
||||
return
|
||||
@ -362,7 +362,7 @@ func Link(c *gin.Context) {
|
||||
//rawPath := stdpath.Join(user.BasePath, req.Path)
|
||||
// why need not join base_path? because it's always the full path
|
||||
rawPath := req.Path
|
||||
storage, err := fs.GetStorage(rawPath)
|
||||
storage, err := fs.GetStorage(rawPath, &fs.GetStoragesArgs{})
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 500)
|
||||
return
|
||||
|
@ -79,14 +79,14 @@ func FsList(c *gin.Context) {
|
||||
common.ErrorStrResp(c, "Refresh without permission", 403)
|
||||
return
|
||||
}
|
||||
objs, err := fs.List(c, reqPath, req.Refresh)
|
||||
objs, err := fs.List(c, reqPath, &fs.ListArgs{Refresh: req.Refresh})
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
total, objs := pagination(objs, &req.PageReq)
|
||||
provider := "unknown"
|
||||
storage, err := fs.GetStorage(reqPath)
|
||||
storage, err := fs.GetStorage(reqPath, &fs.GetStoragesArgs{})
|
||||
if err == nil {
|
||||
provider = storage.GetStorage().Driver
|
||||
}
|
||||
@ -132,7 +132,7 @@ func FsDirs(c *gin.Context) {
|
||||
common.ErrorStrResp(c, "password is incorrect or you have no permission", 403)
|
||||
return
|
||||
}
|
||||
objs, err := fs.List(c, reqPath)
|
||||
objs, err := fs.List(c, reqPath, &fs.ListArgs{})
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 500)
|
||||
return
|
||||
@ -247,14 +247,14 @@ func FsGet(c *gin.Context) {
|
||||
common.ErrorStrResp(c, "password is incorrect or you have no permission", 403)
|
||||
return
|
||||
}
|
||||
obj, err := fs.Get(c, reqPath)
|
||||
obj, err := fs.Get(c, reqPath, &fs.GetArgs{})
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
var rawURL string
|
||||
|
||||
storage, err := fs.GetStorage(reqPath)
|
||||
storage, err := fs.GetStorage(reqPath, &fs.GetStoragesArgs{})
|
||||
provider := "unknown"
|
||||
if err == nil {
|
||||
provider = storage.Config().Name
|
||||
@ -297,7 +297,7 @@ func FsGet(c *gin.Context) {
|
||||
}
|
||||
var related []model.Obj
|
||||
parentPath := stdpath.Dir(reqPath)
|
||||
sameLevelFiles, err := fs.List(c, parentPath)
|
||||
sameLevelFiles, err := fs.List(c, parentPath, &fs.ListArgs{})
|
||||
if err == nil {
|
||||
related = filterRelated(sameLevelFiles, obj)
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ func FsForm(c *gin.Context) {
|
||||
common.ErrorResp(c, err, 403)
|
||||
return
|
||||
}
|
||||
storage, err := fs.GetStorage(path)
|
||||
storage, err := fs.GetStorage(path, &fs.GetStoragesArgs{})
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 400)
|
||||
return
|
||||
|
@ -84,7 +84,7 @@ func walkFS(ctx context.Context, depth int, name string, info model.Obj, walkFn
|
||||
}
|
||||
meta, _ := op.GetNearestMeta(name)
|
||||
// Read directory names.
|
||||
objs, err := fs.List(context.WithValue(ctx, "meta", meta), name)
|
||||
objs, err := fs.List(context.WithValue(ctx, "meta", meta), name, &fs.ListArgs{})
|
||||
//f, err := fs.OpenFile(ctx, name, os.O_RDONLY, 0)
|
||||
//if err != nil {
|
||||
// return walkFn(name, info, err)
|
||||
|
@ -188,7 +188,7 @@ func (h *Handler) handleOptions(w http.ResponseWriter, r *http.Request) (status
|
||||
return 403, err
|
||||
}
|
||||
allow := "OPTIONS, LOCK, PUT, MKCOL"
|
||||
if fi, err := fs.Get(ctx, reqPath); err == nil {
|
||||
if fi, err := fs.Get(ctx, reqPath, &fs.GetArgs{}); err == nil {
|
||||
if fi.IsDir() {
|
||||
allow = "OPTIONS, LOCK, DELETE, PROPPATCH, COPY, MOVE, UNLOCK, PROPFIND"
|
||||
} else {
|
||||
@ -215,7 +215,7 @@ func (h *Handler) handleGetHeadPost(w http.ResponseWriter, r *http.Request) (sta
|
||||
if err != nil {
|
||||
return 403, err
|
||||
}
|
||||
fi, err := fs.Get(ctx, reqPath)
|
||||
fi, err := fs.Get(ctx, reqPath, &fs.GetArgs{})
|
||||
if err != nil {
|
||||
return http.StatusNotFound, err
|
||||
}
|
||||
@ -228,7 +228,7 @@ func (h *Handler) handleGetHeadPost(w http.ResponseWriter, r *http.Request) (sta
|
||||
}
|
||||
w.Header().Set("ETag", etag)
|
||||
// Let ServeContent determine the Content-Type header.
|
||||
storage, _ := fs.GetStorage(reqPath)
|
||||
storage, _ := fs.GetStorage(reqPath, &fs.GetStoragesArgs{})
|
||||
downProxyUrl := storage.GetStorage().DownProxyUrl
|
||||
if storage.GetStorage().WebdavNative() || (storage.GetStorage().WebdavProxy() && downProxyUrl == "") {
|
||||
link, _, err := fs.Link(ctx, reqPath, model.LinkArgs{Header: r.Header})
|
||||
@ -278,7 +278,7 @@ func (h *Handler) handleDelete(w http.ResponseWriter, r *http.Request) (status i
|
||||
// "godoc os RemoveAll" says that "If the path does not exist, RemoveAll
|
||||
// returns nil (no error)." WebDAV semantics are that it should return a
|
||||
// "404 Not Found". We therefore have to Stat before we RemoveAll.
|
||||
if _, err := fs.Get(ctx, reqPath); err != nil {
|
||||
if _, err := fs.Get(ctx, reqPath, &fs.GetArgs{}); err != nil {
|
||||
if errs.IsObjectNotFound(err) {
|
||||
return http.StatusNotFound, err
|
||||
}
|
||||
@ -331,7 +331,7 @@ func (h *Handler) handlePut(w http.ResponseWriter, r *http.Request) (status int,
|
||||
if err != nil {
|
||||
return http.StatusMethodNotAllowed, err
|
||||
}
|
||||
fi, err := fs.Get(ctx, reqPath)
|
||||
fi, err := fs.Get(ctx, reqPath, &fs.GetArgs{})
|
||||
if err != nil {
|
||||
fi = &obj
|
||||
}
|
||||
@ -591,7 +591,7 @@ func (h *Handler) handlePropfind(w http.ResponseWriter, r *http.Request) (status
|
||||
if err != nil {
|
||||
return 403, err
|
||||
}
|
||||
fi, err := fs.Get(ctx, reqPath)
|
||||
fi, err := fs.Get(ctx, reqPath, &fs.GetArgs{})
|
||||
if err != nil {
|
||||
if errs.IsObjectNotFound(err) {
|
||||
return http.StatusNotFound, err
|
||||
@ -670,7 +670,7 @@ func (h *Handler) handleProppatch(w http.ResponseWriter, r *http.Request) (statu
|
||||
if err != nil {
|
||||
return 403, err
|
||||
}
|
||||
if _, err := fs.Get(ctx, reqPath); err != nil {
|
||||
if _, err := fs.Get(ctx, reqPath, &fs.GetArgs{}); err != nil {
|
||||
if errs.IsObjectNotFound(err) {
|
||||
return http.StatusNotFound, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user