chore: add `provider` to fs list resp

pull/1831/head
Noah Hsu 2022-09-22 16:04:10 +08:00
parent b71ecc8e89
commit c7f6684eed
1 changed files with 15 additions and 8 deletions

View File

@ -46,6 +46,7 @@ type FsListResp struct {
Total int64 `json:"total"` Total int64 `json:"total"`
Readme string `json:"readme"` Readme string `json:"readme"`
Write bool `json:"write"` Write bool `json:"write"`
Provider string `json:"provider"`
} }
func FsList(c *gin.Context) { func FsList(c *gin.Context) {
@ -79,11 +80,17 @@ func FsList(c *gin.Context) {
return return
} }
total, objs := pagination(objs, &req.PageReq) total, objs := pagination(objs, &req.PageReq)
provider := "unknown"
storage, err := fs.GetStorage(req.Path)
if err == nil {
provider = storage.GetStorage().Driver
}
common.SuccessResp(c, FsListResp{ common.SuccessResp(c, FsListResp{
Content: toObjResp(objs, isEncrypt(meta, req.Path)), Content: toObjResp(objs, isEncrypt(meta, req.Path)),
Total: int64(total), Total: int64(total),
Readme: getReadme(meta, req.Path), Readme: getReadme(meta, req.Path),
Write: user.CanWrite() || canWrite(meta, req.Path), Write: user.CanWrite() || canWrite(meta, req.Path),
Provider: provider,
}) })
} }