mirror of
https://github.com/gilbertchen/duplicacy
synced 2025-12-06 00:03:38 +00:00
Improve WebDAV performance
This commit is contained in:
@@ -128,7 +128,12 @@ func (storage *WebDAVStorage) sendRequest(method string, uri string, depth int,
|
||||
dataReader = bytes.NewReader(data)
|
||||
} else if method == "PUT" {
|
||||
headers["Content-Type"] = "application/octet-stream"
|
||||
dataReader = CreateRateLimitedReader(data, storage.UploadRateLimit/storage.threads)
|
||||
headers["Content-Length"] = fmt.Sprintf("%d", len(data))
|
||||
if storage.UploadRateLimit <= 0 {
|
||||
dataReader = bytes.NewReader(data)
|
||||
} else {
|
||||
dataReader = CreateRateLimitedReader(data, storage.UploadRateLimit/storage.threads)
|
||||
}
|
||||
} else if method == "MOVE" {
|
||||
headers["Destination"] = storage.createConnectionString(string(data))
|
||||
headers["Content-Type"] = "application/octet-stream"
|
||||
@@ -169,6 +174,7 @@ func (storage *WebDAVStorage) sendRequest(method string, uri string, depth int,
|
||||
return nil, nil, errWebDAVMovedPermanently
|
||||
}
|
||||
|
||||
io.Copy(ioutil.Discard, response.Body)
|
||||
response.Body.Close()
|
||||
if response.StatusCode == 404 {
|
||||
// Retry if it is UPLOAD, otherwise return immediately
|
||||
@@ -351,6 +357,7 @@ func (storage *WebDAVStorage) DeleteFile(threadIndex int, filePath string) (err
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
io.Copy(ioutil.Discard, readCloser)
|
||||
readCloser.Close()
|
||||
return nil
|
||||
}
|
||||
@@ -361,6 +368,7 @@ func (storage *WebDAVStorage) MoveFile(threadIndex int, from string, to string)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
io.Copy(ioutil.Discard, readCloser)
|
||||
readCloser.Close()
|
||||
return nil
|
||||
}
|
||||
@@ -412,6 +420,7 @@ func (storage *WebDAVStorage) CreateDirectory(threadIndex int, dir string) (err
|
||||
}
|
||||
return err
|
||||
}
|
||||
io.Copy(ioutil.Discard, readCloser)
|
||||
readCloser.Close()
|
||||
return nil
|
||||
}
|
||||
@@ -437,6 +446,7 @@ func (storage *WebDAVStorage) UploadFile(threadIndex int, filePath string, conte
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
io.Copy(ioutil.Discard, readCloser)
|
||||
readCloser.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user