From fe854d469dbd31b4165b3062bb727e5aa1e3be9d Mon Sep 17 00:00:00 2001 From: Gilbert Chen Date: Tue, 2 Jun 2020 11:37:12 -0400 Subject: [PATCH] Error out in the check command if there are 0-size chunks. --- src/duplicacy_snapshotmanager.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/duplicacy_snapshotmanager.go b/src/duplicacy_snapshotmanager.go index 2b0ddb9..55053bf 100644 --- a/src/duplicacy_snapshotmanager.go +++ b/src/duplicacy_snapshotmanager.go @@ -821,6 +821,8 @@ func (manager *SnapshotManager) CheckSnapshots(snapshotID string, revisionsToChe // Store the index of the snapshot that references each chunk; if the chunk is shared by multiple chunks, the index is -1 chunkSnapshotMap := make(map[string]int) + emptyChunks := 0 + LOG_INFO("SNAPSHOT_CHECK", "Listing all chunks") allChunks, allSizes := manager.ListAllFiles(manager.storage, chunkDir) @@ -835,6 +837,11 @@ func (manager *SnapshotManager) CheckSnapshots(snapshotID string, revisionsToChe chunk = strings.Replace(chunk, "/", "", -1) chunkSizeMap[chunk] = allSizes[i] + + if allSizes[i] == 0 { + LOG_WARN("SNAPSHOT_CHECK", "Chunk %s has a size of 0", chunk) + emptyChunks++ + } } if snapshotID == "" || showStatistics || showTabular { @@ -991,6 +998,11 @@ func (manager *SnapshotManager) CheckSnapshots(snapshotID string, revisionsToChe return false } + if emptyChunks > 0 { + LOG_ERROR("SNAPSHOT_CHECK", "%d chunks have a size of 0", emptyChunks) + return false + } + if showTabular { manager.ShowStatisticsTabular(snapshotMap, chunkSizeMap, chunkUniqueMap, chunkSnapshotMap) } else if showStatistics {