From 5d459990777cc955c5de0b263cae0aef7dfb467f Mon Sep 17 00:00:00 2001 From: Gilbert Chen Date: Wed, 10 Jun 2020 10:08:53 -0400 Subject: [PATCH] Clear the loaded content after a snapshot has been verified The snapshot content is loaded before verifying the snapshot, but after that it isn't used anymore so it should be released to save memory. --- src/duplicacy_snapshotmanager.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/duplicacy_snapshotmanager.go b/src/duplicacy_snapshotmanager.go index 55053bf..0b1fcdf 100644 --- a/src/duplicacy_snapshotmanager.go +++ b/src/duplicacy_snapshotmanager.go @@ -381,6 +381,13 @@ func (manager *SnapshotManager) DownloadSnapshotContents(snapshot *Snapshot, pat return true } +// ClearSnapshotContents removes contents loaded by DownloadSnapshotContents +func (manager *SnapshotManager) ClearSnapshotContents(snapshot *Snapshot) { + snapshot.ChunkHashes = nil + snapshot.ChunkLengths = nil + snapshot.Files = nil +} + // CleanSnapshotCache removes all files not referenced by the specified 'snapshot' in the snapshot cache. func (manager *SnapshotManager) CleanSnapshotCache(latestSnapshot *Snapshot, allSnapshots map[string][]*Snapshot) bool { @@ -906,6 +913,7 @@ func (manager *SnapshotManager) CheckSnapshots(snapshotID string, revisionsToChe if checkFiles { manager.DownloadSnapshotContents(snapshot, nil, false) manager.VerifySnapshot(snapshot) + manager.ClearSnapshotContents(snapshot) continue }