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.
This commit is contained in:
Gilbert Chen
2020-06-10 10:08:53 -04:00
parent 1adcf56890
commit 5d45999077

View File

@@ -381,6 +381,13 @@ func (manager *SnapshotManager) DownloadSnapshotContents(snapshot *Snapshot, pat
return true 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. // 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 { func (manager *SnapshotManager) CleanSnapshotCache(latestSnapshot *Snapshot, allSnapshots map[string][]*Snapshot) bool {
@@ -906,6 +913,7 @@ func (manager *SnapshotManager) CheckSnapshots(snapshotID string, revisionsToChe
if checkFiles { if checkFiles {
manager.DownloadSnapshotContents(snapshot, nil, false) manager.DownloadSnapshotContents(snapshot, nil, false)
manager.VerifySnapshot(snapshot) manager.VerifySnapshot(snapshot)
manager.ClearSnapshotContents(snapshot)
continue continue
} }