Skip to content

Commit

Permalink
snapshots: add metadata.db for serve cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: abushwang <[email protected]>
  • Loading branch information
wswsmao committed Dec 3, 2024
1 parent a6894ec commit 49aba3a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions snapshot/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,15 @@ func (o *snapshotter) cleanup(ctx context.Context, cleanupCommitted bool) error
return nil
}

func (o *snapshotter) cleanupMetadataDB() error {
metadataDBPath := filepath.Join(o.root, "metadata.db")
err := os.Remove(metadataDBPath)
if err != nil {
return err
}
return nil
}

func (o *snapshotter) cleanupDirectories(ctx context.Context, cleanupCommitted bool) ([]string, error) {
// Get a write transaction to ensure no other write transaction can be entered
// while the cleanup is scanning.
Expand Down Expand Up @@ -658,6 +667,11 @@ func (o *snapshotter) Close() error {
if err := o.cleanup(ctx, cleanupCommitted); err != nil {
log.G(ctx).WithError(err).Warn("failed to cleanup")
}

if err := o.cleanupMetadataDB(); err != nil {
log.G(ctx).WithError(err).Warn("failed to cleanup metadata.db")
}

return o.ms.Close()
}

Expand Down

0 comments on commit 49aba3a

Please sign in to comment.