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

Save the list of verified chunks every 5 minutes.

This can be useful if the list isn't saved at the end of the run for some
reason, such as when the program is terminated abruptly.
This commit is contained in:
Gilbert Chen
2024-07-11 14:12:12 -04:00
parent b659456f12
commit f8a0964ac0

View File

@@ -1032,6 +1032,7 @@ func (manager *SnapshotManager) CheckSnapshots(snapshotID string, revisionsToChe
LOG_WARN("SNAPSHOT_VERIFY", "Failed to save the verified chunks file: %v", err)
} else {
LOG_INFO("SNAPSHOT_VERIFY", "Added %d chunks to the list of verified chunks", len(verifiedChunks) - numberOfVerifiedChunks)
numberOfVerifiedChunks = len(verifiedChunks)
}
}
}
@@ -1063,6 +1064,7 @@ func (manager *SnapshotManager) CheckSnapshots(snapshotID string, revisionsToChe
var totalDownloadedChunkSize int64
var totalDownloadedChunks int64
totalChunks := int64(len(chunkHashes))
lastSaveTime := time.Now().Unix()
chunkChannel := make(chan int, threads)
var wg sync.WaitGroup
@@ -1087,8 +1089,15 @@ func (manager *SnapshotManager) CheckSnapshots(snapshotID string, revisionsToChe
if !chunk.isBroken {
chunkID := manager.config.GetChunkIDFromHash(chunkHashes[chunkIndex])
verifiedChunksLock.Lock()
verifiedChunks[chunkID] = startTime.Unix()
verifiedChunksLock.Unlock()
now := time.Now().Unix()
verifiedChunks[chunkID] = now
if now > lastSaveTime + 5 * 60 {
lastSaveTime = now
verifiedChunksLock.Unlock()
saveVerifiedChunks()
} else {
verifiedChunksLock.Unlock()
}
downloadedChunkSize := atomic.AddInt64(&totalDownloadedChunkSize, int64(chunk.GetLength()))
downloadedChunks := atomic.AddInt64(&totalDownloadedChunks, 1)