Skip to content

Commit

Permalink
fix: only file have raw_url
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Jul 8, 2022
1 parent 90283ef commit e28c1e4
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions server/controllers/fsread.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,25 +161,27 @@ func FsGet(c *gin.Context) {
return
}
var rawURL string
// obj have raw url
if u, ok := obj.(model.URL); ok {
rawURL = u.URL()
} else {
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()))
}
// file have raw url
if !obj.IsDir() {
if u, ok := obj.(model.URL); ok {
rawURL = u.URL()
} 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
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 {
// 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{
Expand Down

0 comments on commit e28c1e4

Please sign in to comment.