* fix(crypt): premature close of MFile * refactor
This commit is contained in:
@ -7,6 +7,7 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
"github.com/alist-org/alist/v3/internal/net"
|
||||
@ -102,11 +103,15 @@ func attachHeader(w http.ResponseWriter, file model.Obj) {
|
||||
w.Header().Set("Etag", GetEtag(file))
|
||||
}
|
||||
func GetEtag(file model.Obj) string {
|
||||
hash := ""
|
||||
for _, v := range file.GetHash().Export() {
|
||||
if len(v) != 0 {
|
||||
return fmt.Sprintf(`"%s"`, v)
|
||||
if strings.Compare(v, hash) > 0 {
|
||||
hash = v
|
||||
}
|
||||
}
|
||||
if len(hash) > 0 {
|
||||
return fmt.Sprintf(`"%s"`, hash)
|
||||
}
|
||||
// 参考nginx
|
||||
return fmt.Sprintf(`"%x-%x"`, file.ModTime().Unix(), file.GetSize())
|
||||
}
|
||||
|
Reference in New Issue
Block a user