snapshot: preserve normal snapshots during cleanup by ChengyuZhu6 · Pull Request #2127 · containerd/stargz-snapshotter (original) (raw)
Instead of giving two different meanings to ids depending on cleanupCommited value, can you just add a remoteSnapshotNames := make(map[string]struct{}) which caches all remote snapshot names and do something like the following in the loop at L459?
for _, d := range dirs { if !cleanupCommitted { if _, ok := ids[d]; ok { continue } } else { if _, ok := remoteSnapshotNames[d]; !ok { continue // do not delete local snapshots } }
cleanup = append(cleanup, filepath.Join(snapshotDir, d))}