fix: only file have raw_url

refactor/fs
Noah Hsu 2022-07-08 15:56:29 +08:00
parent 90283ef29c
commit e28c1e436d
1 changed files with 19 additions and 17 deletions

View File

@ -161,25 +161,27 @@ func FsGet(c *gin.Context) {
return return
} }
var rawURL string var rawURL string
// obj have raw url // file have raw url
if u, ok := obj.(model.URL); ok { if !obj.IsDir() {
rawURL = u.URL() if u, ok := obj.(model.URL); ok {
} else { rawURL = u.URL()
account, _ := fs.GetAccount(req.Path)
if account.Config().MustProxy() || account.GetAccount().WebProxy {
if account.GetAccount().DownProxyUrl != "" {
rawURL = fmt.Sprintf("%s%s?sign=%s", strings.Split(account.GetAccount().DownProxyUrl, "\n")[0], req.Path, sign.Sign(obj.GetName()))
} else {
rawURL = fmt.Sprintf("%s/p%s?sign=%s", common.GetBaseUrl(c.Request), req.Path, sign.Sign(obj.GetName()))
}
} else { } else {
// if account is not proxy, use raw url by fs.Link account, _ := fs.GetAccount(req.Path)
link, _, err := fs.Link(c, req.Path, model.LinkArgs{}) if account.Config().MustProxy() || account.GetAccount().WebProxy {
if err != nil { if account.GetAccount().DownProxyUrl != "" {
common.ErrorResp(c, err, 500) rawURL = fmt.Sprintf("%s%s?sign=%s", strings.Split(account.GetAccount().DownProxyUrl, "\n")[0], req.Path, sign.Sign(obj.GetName()))
return } else {
rawURL = fmt.Sprintf("%s/p%s?sign=%s", common.GetBaseUrl(c.Request), req.Path, sign.Sign(obj.GetName()))
}
} else {
// if account is not proxy, use raw url by fs.Link
link, _, err := fs.Link(c, req.Path, model.LinkArgs{})
if err != nil {
common.ErrorResp(c, err, 500)
return
}
rawURL = link.URL
} }
rawURL = link.URL
} }
} }
common.SuccessResp(c, FsGetResp{ common.SuccessResp(c, FsGetResp{