diff --git a/drivers/ftp/util.go b/drivers/ftp/util.go index d90d2cd7f9d..8699ab6f543 100644 --- a/drivers/ftp/util.go +++ b/drivers/ftp/util.go @@ -48,10 +48,9 @@ func NewFTPFileReader(conn *ftp.ServerConn, path string) *FTPFileReader { } func (r *FTPFileReader) Read(buf []byte) (n int, err error) { + n, err = r.ReadAt(buf, r.offset) r.mu.Lock() defer r.mu.Unlock() - - n, err = r.ReadAt(buf, r.offset) r.offset += int64(n) return } diff --git a/server/common/proxy.go b/server/common/proxy.go index 65d8d334130..370e46eb21f 100644 --- a/server/common/proxy.go +++ b/server/common/proxy.go @@ -3,20 +3,21 @@ package common import ( "context" "fmt" + "io" + "net/http" + "net/url" + "github.com/alist-org/alist/v3/internal/model" "github.com/alist-org/alist/v3/internal/net" "github.com/alist-org/alist/v3/pkg/http_range" "github.com/alist-org/alist/v3/pkg/utils" - "io" - "net/http" - "net/url" ) func Proxy(w http.ResponseWriter, r *http.Request, link *model.Link, file model.Obj) error { if link.MFile != nil { + defer link.MFile.Close() attachFileName(w, file) http.ServeContent(w, r, file.GetName(), file.ModTime(), link.MFile) - defer link.MFile.Close() return nil } else if link.RangeReadCloser != nil { attachFileName(w, file)