fix(ftp): dead lock on Read (close #5128)

This commit is contained in:
Andy Hsu 2023-08-31 15:10:47 +08:00
parent cb8867fcc1
commit 34fadecc2c
2 changed files with 6 additions and 6 deletions

View File

@ -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
}

View File

@ -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)