mirror of
https://github.com/gilbertchen/duplicacy
synced 2025-12-10 05:13:17 +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)
|
dataReader = bytes.NewReader(data)
|
||||||
} else if method == "PUT" {
|
} else if method == "PUT" {
|
||||||
headers["Content-Type"] = "application/octet-stream"
|
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" {
|
} else if method == "MOVE" {
|
||||||
headers["Destination"] = storage.createConnectionString(string(data))
|
headers["Destination"] = storage.createConnectionString(string(data))
|
||||||
headers["Content-Type"] = "application/octet-stream"
|
headers["Content-Type"] = "application/octet-stream"
|
||||||
@@ -169,6 +174,7 @@ func (storage *WebDAVStorage) sendRequest(method string, uri string, depth int,
|
|||||||
return nil, nil, errWebDAVMovedPermanently
|
return nil, nil, errWebDAVMovedPermanently
|
||||||
}
|
}
|
||||||
|
|
||||||
|
io.Copy(ioutil.Discard, response.Body)
|
||||||
response.Body.Close()
|
response.Body.Close()
|
||||||
if response.StatusCode == 404 {
|
if response.StatusCode == 404 {
|
||||||
// Retry if it is UPLOAD, otherwise return immediately
|
// Retry if it is UPLOAD, otherwise return immediately
|
||||||
@@ -351,6 +357,7 @@ func (storage *WebDAVStorage) DeleteFile(threadIndex int, filePath string) (err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
io.Copy(ioutil.Discard, readCloser)
|
||||||
readCloser.Close()
|
readCloser.Close()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -361,6 +368,7 @@ func (storage *WebDAVStorage) MoveFile(threadIndex int, from string, to string)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
io.Copy(ioutil.Discard, readCloser)
|
||||||
readCloser.Close()
|
readCloser.Close()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -412,6 +420,7 @@ func (storage *WebDAVStorage) CreateDirectory(threadIndex int, dir string) (err
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
io.Copy(ioutil.Discard, readCloser)
|
||||||
readCloser.Close()
|
readCloser.Close()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -437,6 +446,7 @@ func (storage *WebDAVStorage) UploadFile(threadIndex int, filePath string, conte
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
io.Copy(ioutil.Discard, readCloser)
|
||||||
readCloser.Close()
|
readCloser.Close()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user