sftpd download: remove check for download size
some clients, for example rclone can request only part of a file, we have no way to detect this so we haven't return an error if the downloaded size does not match the file size
This commit is contained in:
parent
0061978db8
commit
b99495ebbb
2 changed files with 0 additions and 37 deletions
|
@ -225,36 +225,6 @@ func TestUploadResumeInvalidOffset(t *testing.T) {
|
|||
os.Remove(testfile)
|
||||
}
|
||||
|
||||
func TestIncompleteDownload(t *testing.T) {
|
||||
testfile := "testfile"
|
||||
file, _ := os.Create(testfile)
|
||||
transfer := Transfer{
|
||||
file: file,
|
||||
path: file.Name(),
|
||||
start: time.Now(),
|
||||
bytesSent: 0,
|
||||
bytesReceived: 0,
|
||||
user: dataprovider.User{
|
||||
Username: "testuser",
|
||||
},
|
||||
connectionID: "",
|
||||
transferType: transferDownload,
|
||||
lastActivity: time.Now(),
|
||||
isNewFile: false,
|
||||
protocol: protocolSFTP,
|
||||
transferError: nil,
|
||||
isFinished: false,
|
||||
minWriteOffset: 0,
|
||||
expectedSize: 10,
|
||||
lock: new(sync.Mutex),
|
||||
}
|
||||
err := transfer.Close()
|
||||
if err == nil || !strings.Contains(err.Error(), "incomplete download") {
|
||||
t.Error("upoload must fail the expected size does not match")
|
||||
}
|
||||
os.Remove(testfile)
|
||||
}
|
||||
|
||||
func TestReadWriteErrors(t *testing.T) {
|
||||
testfile := "testfile"
|
||||
file, _ := os.Create(testfile)
|
||||
|
|
|
@ -131,7 +131,6 @@ func (t *Transfer) Close() error {
|
|||
if t.isNewFile {
|
||||
numFiles = 1
|
||||
}
|
||||
t.checkDownloadSize()
|
||||
metrics.TransferCompleted(t.bytesSent, t.bytesReceived, t.transferType, t.transferError)
|
||||
if t.transferType == transferUpload && t.file != nil && t.file.Name() != t.path {
|
||||
if t.transferError == nil || uploadMode == uploadModeAtomicWithResume {
|
||||
|
@ -192,12 +191,6 @@ func (t *Transfer) updateQuota(numFiles int) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (t *Transfer) checkDownloadSize() {
|
||||
if t.transferType == transferDownload && t.transferError == nil && t.bytesSent < t.expectedSize {
|
||||
t.transferError = fmt.Errorf("incomplete download: %v/%v bytes transferred", t.bytesSent, t.expectedSize)
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Transfer) handleThrottle() {
|
||||
var wantedBandwidth int64
|
||||
var trasferredBytes int64
|
||||
|
|
Loading…
Add table
Reference in a new issue