From 1da151f9d954e034f72252934c95e7bc707abe76 Mon Sep 17 00:00:00 2001 From: Gilbert Chen Date: Sun, 21 Apr 2019 20:32:21 -0400 Subject: [PATCH] Add an additional lookup for a chunk that isn't in the chunk list A chunk not in the chunk list may actually exists in two scenarios: * the chunk may be a special snapshot chunk that contains the chunk sequence, so it may be resurrected by the chunk downloader if it had been turned into a fossil before * if the API to list all chunks doesn't return the complete list due to some bug This additional lookup avoid reporting the missing chunk prematurely. --- src/duplicacy_snapshotmanager.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/duplicacy_snapshotmanager.go b/src/duplicacy_snapshotmanager.go index 2bfefd2..9a80568 100644 --- a/src/duplicacy_snapshotmanager.go +++ b/src/duplicacy_snapshotmanager.go @@ -860,6 +860,20 @@ func (manager *SnapshotManager) CheckSnapshots(snapshotID string, revisionsToChe _, found := chunkSizeMap[chunkID] if !found { + + // Look up the chunk again in case it actually exists, but only if there aren't + // too many missing chunks. + if missingChunks < 100 { + _, exist, _, err := manager.storage.FindChunk(0, chunkID, false) + if err != nil { + LOG_WARN("SNAPSHOT_VALIDATE", "Failed to check the existence of chunk %s: %v", + chunkID, err) + } else if exist { + LOG_INFO("SNAPSHOT_VALIDATE", "Chunk %s is confirmed to exist", chunkID) + continue + } + } + if !searchFossils { missingChunks += 1 LOG_WARN("SNAPSHOT_VALIDATE", @@ -870,7 +884,7 @@ func (manager *SnapshotManager) CheckSnapshots(snapshotID string, revisionsToChe chunkPath, exist, size, err := manager.storage.FindChunk(0, chunkID, true) if err != nil { - LOG_ERROR("SNAPSHOT_VALIDATE", "Failed to check the existence of chunk %s: %v", + LOG_ERROR("SNAPSHOT_VALIDATE", "Failed to check the existence of fossil %s: %v", chunkID, err) return false }