mirror of
https://github.com/gilbertchen/duplicacy
synced 2025-12-10 21:33:19 +00:00
Handle zero-byte files correctly
This commit fixed 2 bugs. The first bug occurs when an incomplete backup contains a zero-byte file and no chunks. The second bug occurs when the repository contains only zero-byte files.
This commit is contained in:
@@ -301,7 +301,7 @@ func (manager *BackupManager) Backup(top string, quickMode bool, threads int, ta
|
|||||||
if compareResult == 0 {
|
if compareResult == 0 {
|
||||||
// No need to check if it is in hash mode -- in that case remote listing is nil
|
// No need to check if it is in hash mode -- in that case remote listing is nil
|
||||||
if localEntry.IsSameAs(remoteEntry) && localEntry.IsFile() {
|
if localEntry.IsSameAs(remoteEntry) && localEntry.IsFile() {
|
||||||
|
if localEntry.Size > 0 {
|
||||||
localEntry.Hash = remoteEntry.Hash
|
localEntry.Hash = remoteEntry.Hash
|
||||||
localEntry.StartOffset = remoteEntry.StartOffset
|
localEntry.StartOffset = remoteEntry.StartOffset
|
||||||
localEntry.EndOffset = remoteEntry.EndOffset
|
localEntry.EndOffset = remoteEntry.EndOffset
|
||||||
@@ -321,6 +321,7 @@ func (manager *BackupManager) Backup(top string, quickMode bool, threads int, ta
|
|||||||
localEntry.StartChunk = remoteEntry.StartChunk - delta
|
localEntry.StartChunk = remoteEntry.StartChunk - delta
|
||||||
localEntry.EndChunk = remoteEntry.EndChunk - delta
|
localEntry.EndChunk = remoteEntry.EndChunk - delta
|
||||||
preservedFileSize += localEntry.Size
|
preservedFileSize += localEntry.Size
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
totalModifiedFileSize += localEntry.Size
|
totalModifiedFileSize += localEntry.Size
|
||||||
if localEntry.Size > 0 {
|
if localEntry.Size > 0 {
|
||||||
@@ -1047,6 +1048,7 @@ func (manager *BackupManager) UploadSnapshot(chunkOperator *ChunkOperator, top s
|
|||||||
|
|
||||||
uploadEntryInfoFunc := func(entry *Entry) error {
|
uploadEntryInfoFunc := func(entry *Entry) error {
|
||||||
|
|
||||||
|
if entry.IsFile() && entry.Size > 0 {
|
||||||
delta := entry.StartChunk - len(chunkHashes) + 1
|
delta := entry.StartChunk - len(chunkHashes) + 1
|
||||||
if entry.StartChunk != lastChunk {
|
if entry.StartChunk != lastChunk {
|
||||||
chunkHashes = append(chunkHashes, snapshot.ChunkHashes[entry.StartChunk])
|
chunkHashes = append(chunkHashes, snapshot.ChunkHashes[entry.StartChunk])
|
||||||
@@ -1063,8 +1065,7 @@ func (manager *BackupManager) UploadSnapshot(chunkOperator *ChunkOperator, top s
|
|||||||
entry.StartChunk -= delta
|
entry.StartChunk -= delta
|
||||||
entry.EndChunk -= delta
|
entry.EndChunk -= delta
|
||||||
|
|
||||||
if entry.IsFile() {
|
delta = entry.EndChunk - entry.StartChunk
|
||||||
delta := entry.EndChunk - entry.StartChunk
|
|
||||||
entry.StartChunk -= lastEndChunk
|
entry.StartChunk -= lastEndChunk
|
||||||
lastEndChunk = entry.EndChunk
|
lastEndChunk = entry.EndChunk
|
||||||
entry.EndChunk = delta
|
entry.EndChunk = delta
|
||||||
|
|||||||
Reference in New Issue
Block a user