From 08e85c49ffda7e24baf42e76acfc10491a241ebc Mon Sep 17 00:00:00 2001 From: Gilbert Chen Date: Fri, 15 Feb 2019 13:56:18 -0500 Subject: [PATCH 1/3] When prefetching chunks don't stop on a chunk that may not be needed --- src/duplicacy_chunkdownloader.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/duplicacy_chunkdownloader.go b/src/duplicacy_chunkdownloader.go index 98867ab..87cb4cb 100644 --- a/src/duplicacy_chunkdownloader.go +++ b/src/duplicacy_chunkdownloader.go @@ -220,7 +220,7 @@ func (downloader *ChunkDownloader) WaitForChunk(chunkIndex int) (chunk *Chunk) { } task := &downloader.taskList[i] if !task.needed { - break + continue } if !task.isDownloading { From 3255d8168a56d13e613ae49ed988e67feb7eb379 Mon Sep 17 00:00:00 2001 From: Gilbert Chen Date: Tue, 26 Feb 2019 13:38:25 -0500 Subject: [PATCH 2/3] Fixed a webdav compatibility issue with rclone and other bugs --- src/duplicacy_webdavstorage.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/duplicacy_webdavstorage.go b/src/duplicacy_webdavstorage.go index 419f71e..c8e9501 100644 --- a/src/duplicacy_webdavstorage.go +++ b/src/duplicacy_webdavstorage.go @@ -49,7 +49,7 @@ var ( ) func CreateWebDAVStorage(host string, port int, username string, password string, storageDir string, useHTTP bool, threads int) (storage *WebDAVStorage, err error) { - if storageDir[len(storageDir)-1] != '/' { + if len(storageDir) > 0 && storageDir[len(storageDir)-1] != '/' { storageDir += "/" } @@ -59,7 +59,7 @@ func CreateWebDAVStorage(host string, port int, username string, password string username: username, password: password, storageDir: "", - useHTTP: false, + useHTTP: useHTTP, client: http.DefaultClient, threads: threads, @@ -313,6 +313,7 @@ func (storage *WebDAVStorage) ListFiles(threadIndex int, dir string) (files []st // GetFileInfo returns the information about the file or directory at 'filePath'. func (storage *WebDAVStorage) GetFileInfo(threadIndex int, filePath string) (exist bool, isDir bool, size int64, err error) { + properties, err := storage.getProperties(filePath, 0, "getcontentlength", "resourcetype") if err != nil { if err == errWebDAVNotExist { @@ -325,7 +326,14 @@ func (storage *WebDAVStorage) GetFileInfo(threadIndex int, filePath string) (exi return false, false, 0, err } - if m, exist := properties["/"+storage.storageDir+filePath]; !exist { + m, exist := properties["/"+storage.storageDir+filePath] + + // If no properties exist for the given filePath, remove the trailing / from filePath and search again + if !exist && filePath != "" && filePath[len(filePath) - 1] == '/' { + m, exist = properties["/"+storage.storageDir+filePath[:len(filePath) - 1]] + } + + if !exist { return false, false, 0, nil } else if resourceType, exist := m["resourcetype"]; exist && strings.Contains(resourceType, "collection") { return true, true, 0, nil From 54c4ebaa99182f53a754c0da9347e1283c90a287 Mon Sep 17 00:00:00 2001 From: Gilbert Chen Date: Tue, 26 Feb 2019 13:55:20 -0500 Subject: [PATCH 3/3] Revert last commit which was checked in to the wrong branch This reverts commit 3255d8168a56d13e613ae49ed988e67feb7eb379. --- src/duplicacy_webdavstorage.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/duplicacy_webdavstorage.go b/src/duplicacy_webdavstorage.go index c8e9501..419f71e 100644 --- a/src/duplicacy_webdavstorage.go +++ b/src/duplicacy_webdavstorage.go @@ -49,7 +49,7 @@ var ( ) func CreateWebDAVStorage(host string, port int, username string, password string, storageDir string, useHTTP bool, threads int) (storage *WebDAVStorage, err error) { - if len(storageDir) > 0 && storageDir[len(storageDir)-1] != '/' { + if storageDir[len(storageDir)-1] != '/' { storageDir += "/" } @@ -59,7 +59,7 @@ func CreateWebDAVStorage(host string, port int, username string, password string username: username, password: password, storageDir: "", - useHTTP: useHTTP, + useHTTP: false, client: http.DefaultClient, threads: threads, @@ -313,7 +313,6 @@ func (storage *WebDAVStorage) ListFiles(threadIndex int, dir string) (files []st // GetFileInfo returns the information about the file or directory at 'filePath'. func (storage *WebDAVStorage) GetFileInfo(threadIndex int, filePath string) (exist bool, isDir bool, size int64, err error) { - properties, err := storage.getProperties(filePath, 0, "getcontentlength", "resourcetype") if err != nil { if err == errWebDAVNotExist { @@ -326,14 +325,7 @@ func (storage *WebDAVStorage) GetFileInfo(threadIndex int, filePath string) (exi return false, false, 0, err } - m, exist := properties["/"+storage.storageDir+filePath] - - // If no properties exist for the given filePath, remove the trailing / from filePath and search again - if !exist && filePath != "" && filePath[len(filePath) - 1] == '/' { - m, exist = properties["/"+storage.storageDir+filePath[:len(filePath) - 1]] - } - - if !exist { + if m, exist := properties["/"+storage.storageDir+filePath]; !exist { return false, false, 0, nil } else if resourceType, exist := m["resourcetype"]; exist && strings.Contains(resourceType, "collection") { return true, true, 0, nil