httpd/webdav: use a custom listener with read and write deadlines

This commit is contained in:
Nicola Murino
2021-05-07 20:41:20 +02:00
parent d4bfc3f6b5
commit 4ea4202b99
12 changed files with 133 additions and 48 deletions

View File

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