From a6d071e1b55a944c11afb6c342c08522c58c32f7 Mon Sep 17 00:00:00 2001 From: Gilbert Chen Date: Fri, 10 Nov 2017 13:59:12 -0500 Subject: [PATCH] Fixed a bug in splitting the existing file that caused all chunks to be redownloaded --- src/duplicacy_backupmanager.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/duplicacy_backupmanager.go b/src/duplicacy_backupmanager.go index fd5c162..232e939 100644 --- a/src/duplicacy_backupmanager.go +++ b/src/duplicacy_backupmanager.go @@ -1212,13 +1212,15 @@ func (manager *BackupManager) RestoreFile(chunkDownloader *ChunkDownloader, chun // truncated portion of the existing file for i := entry.StartChunk; i <= entry.EndChunk+1; i++ { hasher := manager.config.NewKeyedHasher(manager.config.HashKey) - chunkSize := 1 // the size of extra chunk beyond EndChunk + chunkSize := 0 if i == entry.StartChunk { - chunkSize -= entry.StartOffset + chunkSize = chunkDownloader.taskList[i].chunkLength - entry.StartOffset } else if i == entry.EndChunk { chunkSize = entry.EndOffset } else if i > entry.StartChunk && i < entry.EndChunk { chunkSize = chunkDownloader.taskList[i].chunkLength + } else { + chunkSize = 1 // the size of extra chunk beyond EndChunk } count := 0 for count < chunkSize {