1
0
mirror of https://github.com/gilbertchen/duplicacy synced 2025-12-06 00:03:38 +00:00

Fixed a bug that caused restoration of two adjacent files to crash

This commit is contained in:
Gilbert Chen
2017-06-09 21:05:44 -04:00
parent 26f2ebd8dd
commit dd11641611
2 changed files with 15 additions and 1 deletions

View File

@@ -267,6 +267,20 @@ func TestBackupManager(t *testing.T) {
}
}
// Remove file2 and dir1/file3 and restore them from revision 3
os.Remove(testDir + "/repository1/file2")
os.Remove(testDir + "/repository1/dir1/file3")
backupManager.Restore(testDir + "/repository1", 3, /*inPlace=*/true, /*quickMode=*/false, threads, /*overwrite=*/true,
/*deleteMode=*/false, /*showStatistics=*/false, /*patterns=*/[]string{"+file2", "+dir1/file3", "-*"})
for _, f := range []string{ "file1", "file2", "dir1/file3" } {
hash1 := getFileHash(testDir + "/repository1/" + f)
hash2 := getFileHash(testDir + "/repository2/" + f)
if hash1 != hash2 {
t.Errorf("File %s has different hashes: %s vs %s", f, hash1, hash2)
}
}
/*buf := make([]byte, 1<<16)
runtime.Stack(buf, true)
fmt.Printf("%s", buf)*/

View File

@@ -110,7 +110,7 @@ func (downloader *ChunkDownloader) AddFiles(snapshot *Snapshot, files [] *Entry)
}
downloader.taskList = append(downloader.taskList, task)
} else {
downloader.taskList[lastChunkIndex].needed = true
downloader.taskList[len(downloader.taskList) - 1].needed = true
}
lastChunkIndex = i
}