Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions drivers/crypt/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,9 @@ func (d *Crypt) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (
if err != nil {
return nil, err
}
// 可以直接返回,读取完也不会调用Close,直到连接断开Close
return remoteLink.MFile, nil
//keep reuse same MFile and close at last.
remoteClosers.Add(remoteLink.MFile)
return io.NopCloser(remoteLink.MFile), nil
}

return nil, errs.NotSupport
Expand Down
9 changes: 7 additions & 2 deletions server/common/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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())
}
Expand Down
Loading