fix: DProxyTypes judge

pull/823/head
Xhofe 2022-03-22 19:53:26 +08:00
parent 9e483d902f
commit db275f885a
4 changed files with 5 additions and 12 deletions

View File

@ -7,7 +7,6 @@ import (
"github.com/Xhofe/alist/utils" "github.com/Xhofe/alist/utils"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"path"
) )
func Down(c *gin.Context) { func Down(c *gin.Context) {
@ -19,7 +18,7 @@ func Down(c *gin.Context) {
common.ErrorResp(c, err, 500) common.ErrorResp(c, err, 500)
return return
} }
if driver.Config().OnlyProxy || account.Proxy || utils.IsContain(conf.DProxyTypes, path.Ext(rawPath)) { if driver.Config().OnlyProxy || account.Proxy || utils.IsContain(conf.DProxyTypes, utils.Ext(rawPath)) {
Proxy(c) Proxy(c)
return return
} }

View File

@ -30,7 +30,7 @@ func Proxy(c *gin.Context) {
// 4. 开启webdav中转需要验证sign // 4. 开启webdav中转需要验证sign
if !account.Proxy && !driver.Config().OnlyProxy && if !account.Proxy && !driver.Config().OnlyProxy &&
utils.GetFileType(filepath.Ext(rawPath)) != conf.TEXT && utils.GetFileType(filepath.Ext(rawPath)) != conf.TEXT &&
!utils.IsContain(conf.DProxyTypes, filepath.Ext(rawPath)) { !utils.IsContain(conf.DProxyTypes, utils.Ext(rawPath)) {
// 只开启了webdav中转验证sign // 只开启了webdav中转验证sign
ok := false ok := false
if account.WebdavProxy { if account.WebdavProxy {

View File

@ -35,7 +35,7 @@ func GetFileType(ext string) int {
if ext == "" { if ext == "" {
return conf.UNKNOWN return conf.UNKNOWN
} }
ext = strings.ToLower(strings.TrimLeft(ext, ".")) ext = strings.ToLower(strings.TrimPrefix(ext, "."))
if IsContain(conf.OfficeTypes, ext) { if IsContain(conf.OfficeTypes, ext) {
return conf.OFFICE return conf.OFFICE
} }
@ -128,10 +128,6 @@ func Split(p string) (string, string) {
return path.Split(p) return path.Split(p)
} }
// FormatName TODO func Ext(name string) string {
func FormatName(name string) string { return strings.TrimPrefix(path.Ext(name), ".")
name = strings.ReplaceAll(name, "/", " ")
name = strings.ReplaceAll(name, "#", " ")
name = strings.ReplaceAll(name, "?", " ")
return name
} }

View File

@ -13,14 +13,12 @@ func GetSHA1Encode(data string) string {
return hex.EncodeToString(h.Sum(nil)) return hex.EncodeToString(h.Sum(nil))
} }
// GetMD5Encode
func GetMD5Encode(data string) string { func GetMD5Encode(data string) string {
h := md5.New() h := md5.New()
h.Write([]byte(data)) h.Write([]byte(data))
return hex.EncodeToString(h.Sum(nil)) return hex.EncodeToString(h.Sum(nil))
} }
// Get16MD5Encode
func Get16MD5Encode(data string) string { func Get16MD5Encode(data string) string {
return GetMD5Encode(data)[8:24] return GetMD5Encode(data)[8:24]
} }