mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 06:40:54 +03:00
httpd/webdav: use a custom listener with read and write deadlines
This commit is contained in:
@@ -2348,6 +2348,17 @@ func checkBasicFunc(client *gowebdav.Client) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func checkFileSize(remoteDestPath string, expectedSize int64, client *gowebdav.Client) error {
|
||||
info, err := client.Stat(remoteDestPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if info.Size() != expectedSize {
|
||||
return fmt.Errorf("uploaded file size does not match, actual: %v, expected: %v", info.Size(), expectedSize)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func uploadFile(localSourcePath string, remoteDestPath string, expectedSize int64, client *gowebdav.Client) error {
|
||||
srcFile, err := os.Open(localSourcePath)
|
||||
if err != nil {
|
||||
@@ -2359,12 +2370,10 @@ func uploadFile(localSourcePath string, remoteDestPath string, expectedSize int6
|
||||
return err
|
||||
}
|
||||
if expectedSize > 0 {
|
||||
info, err := client.Stat(remoteDestPath)
|
||||
err = checkFileSize(remoteDestPath, expectedSize, client)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if info.Size() != expectedSize {
|
||||
return fmt.Errorf("uploaded file size does not match, actual: %v, expected: %v", info.Size(), expectedSize)
|
||||
time.Sleep(1 * time.Second)
|
||||
return checkFileSize(remoteDestPath, expectedSize, client)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user