Skip to content
This repository was archived by the owner on Jan 3, 2026. It is now read-only.

Commit bc705e1

Browse files
committed
fix(crypt): MFile 过早关闭 (AlistGo#8132 关闭 AlistGo#8119)
1 parent d818ee3 commit bc705e1

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

drivers/crypt/driver.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,9 @@ func (d *Crypt) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (
282282
if err != nil {
283283
return nil, err
284284
}
285-
// 可以直接返回,读取完也不会调用Close,直到连接断开Close
286-
return remoteLink.MFile, nil
285+
//keep reuse same MFile and close at last.
286+
remoteClosers.Add(remoteLink.MFile)
287+
return io.NopCloser(remoteLink.MFile), nil
287288
}
288289

289290
return nil, errs.NotSupport

server/common/proxy.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"net/http"
88
"net/url"
99
"os"
10+
"strings"
1011

1112
"github.com/alist-org/alist/v3/internal/model"
1213
"github.com/alist-org/alist/v3/internal/net"
@@ -102,11 +103,15 @@ func attachHeader(w http.ResponseWriter, file model.Obj) {
102103
w.Header().Set("Etag", GetEtag(file))
103104
}
104105
func GetEtag(file model.Obj) string {
106+
hash := ""
105107
for _, v := range file.GetHash().Export() {
106-
if len(v) != 0 {
107-
return fmt.Sprintf(`"%s"`, v)
108+
if strings.Compare(v, hash) > 0 {
109+
hash = v
108110
}
109111
}
112+
if len(hash) > 0 {
113+
return fmt.Sprintf(`"%s"`, hash)
114+
}
110115
// 参考nginx
111116
return fmt.Sprintf(`"%x-%x"`, file.ModTime().Unix(), file.GetSize())
112117
}

0 commit comments

Comments
 (0)