mirror of
https://github.com/jkl1337/duplicacy.git
synced 2026-01-02 19:54:54 -06:00
Fixed a bug that caused a truncated file not to be restored correctly
This commit is contained in:
@@ -1196,13 +1196,17 @@ func (manager *BackupManager) RestoreFile(chunkDownloader *ChunkDownloader, chun
|
|||||||
fileHasher := manager.config.NewFileHasher()
|
fileHasher := manager.config.NewFileHasher()
|
||||||
buffer := make([]byte, 64 * 1024)
|
buffer := make([]byte, 64 * 1024)
|
||||||
err = nil
|
err = nil
|
||||||
for i := entry.StartChunk; i <= entry.EndChunk; i++ {
|
// We set to read one more byte so the file hash will be different if the file to be restored is a
|
||||||
|
// truncated portion of the existing file
|
||||||
|
for i := entry.StartChunk; i <= entry.EndChunk + 1; i++ {
|
||||||
hasher := manager.config.NewKeyedHasher(manager.config.HashKey)
|
hasher := manager.config.NewKeyedHasher(manager.config.HashKey)
|
||||||
chunkSize := chunkDownloader.taskList[i].chunkLength
|
chunkSize := 1 // the size of extra chunk beyond EndChunk
|
||||||
if i == entry.StartChunk {
|
if i == entry.StartChunk {
|
||||||
chunkSize -= entry.StartOffset
|
chunkSize -= entry.StartOffset
|
||||||
} else if i == entry.EndChunk {
|
} else if i == entry.EndChunk {
|
||||||
chunkSize = entry.EndOffset
|
chunkSize = entry.EndOffset
|
||||||
|
} else if i > entry.StartChunk && i < entry.EndChunk {
|
||||||
|
chunkSize = chunkDownloader.taskList[i].chunkLength
|
||||||
}
|
}
|
||||||
count := 0
|
count := 0
|
||||||
for count < chunkSize {
|
for count < chunkSize {
|
||||||
|
|||||||
Reference in New Issue
Block a user