Add overlay cleanup
Updates overlay remove to simply remove the reference, adds a cleanup method for discarding the directory. Updates snapshot create to setup the directory structure while in the transaction, to prevent cleanup from removing directories which are part of a create. Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
@@ -597,14 +597,23 @@ func validateSnapshot(info *snapshots.Info) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type cleaner interface {
|
||||
Cleanup(ctx context.Context) error
|
||||
}
|
||||
|
||||
func (s *snapshotter) garbageCollect(ctx context.Context) (d time.Duration, err error) {
|
||||
s.l.Lock()
|
||||
t1 := time.Now()
|
||||
defer func() {
|
||||
s.l.Unlock()
|
||||
if err == nil {
|
||||
if c, ok := s.Snapshotter.(cleaner); ok {
|
||||
err = c.Cleanup(ctx)
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
d = time.Now().Sub(t1)
|
||||
}
|
||||
s.l.Unlock()
|
||||
}()
|
||||
|
||||
seen := map[string]struct{}{}
|
||||
|
||||
Reference in New Issue
Block a user