Skip to content

Commit

Permalink
fix(ftp): dead lock on Read (close #5128)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Aug 31, 2023
1 parent cb8867f commit 34fadec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
3 changes: 1 addition & 2 deletions drivers/ftp/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
9 changes: 5 additions & 4 deletions server/common/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 34fadec

Please sign in to comment.