Skip to content

Commit

Permalink
fix: update chunkmap suffix
Browse files Browse the repository at this point in the history
Signed-off-by: Yadong Ding <ding_yadong@foxmail.com>
  • Loading branch information
Desiki-high committed Oct 10, 2024
1 parent d42d55a commit 3a98b05
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/cache/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,15 @@ func (m *Manager) CacheUsage(ctx context.Context, blobID string) (snapshots.Usag
var usage snapshots.Usage

blobCachePath := path.Join(m.cacheDir, blobID)
blobChunkMap := path.Join(m.cacheDir, blobID+chunkMapFileSuffix)
// For backward compatibility
blobCacheSuffixedPath := path.Join(m.cacheDir, blobID+dataFileSuffix)
blobChunkMap := path.Join(m.cacheDir, blobID+chunkMapFileSuffix)
blobChunkMapSuffixedPath := path.Join(m.cacheDir, blobID+dataFileSuffix+chunkMapFileSuffix)
blobMeta := path.Join(m.cacheDir, blobID+metaFileSuffix)
imageDisk := path.Join(m.cacheDir, blobID+imageDiskFileSuffix)
layerDisk := path.Join(m.cacheDir, blobID+layerDiskFileSuffix)

stuffs := []string{blobCachePath, blobCacheSuffixedPath, blobChunkMap, blobMeta, imageDisk, layerDisk}
stuffs := []string{blobCachePath, blobChunkMap, blobCacheSuffixedPath, blobChunkMapSuffixedPath, blobMeta, imageDisk, layerDisk}

for _, f := range stuffs {
du, err := fs.DiskUsage(ctx, f)
Expand All @@ -97,14 +98,15 @@ func (m *Manager) CacheUsage(ctx context.Context, blobID string) (snapshots.Usag

func (m *Manager) RemoveBlobCache(blobID string) error {
blobCachePath := path.Join(m.cacheDir, blobID)
blobCacheSuffixedPath := path.Join(m.cacheDir, blobID+dataFileSuffix)
blobChunkMap := path.Join(m.cacheDir, blobID+chunkMapFileSuffix)
blobCacheSuffixedPath := path.Join(m.cacheDir, blobID+dataFileSuffix)
blobChunkMapSuffixedPath := path.Join(m.cacheDir, blobID+dataFileSuffix+chunkMapFileSuffix)
blobMeta := path.Join(m.cacheDir, blobID+metaFileSuffix)
imageDisk := path.Join(m.cacheDir, blobID+imageDiskFileSuffix)
layerDisk := path.Join(m.cacheDir, blobID+layerDiskFileSuffix)

// NOTE: Delete chunk bitmap file before data blob
stuffs := []string{blobChunkMap, blobMeta, blobCachePath, blobCacheSuffixedPath, imageDisk, layerDisk}
stuffs := []string{blobChunkMap, blobChunkMapSuffixedPath, blobMeta, blobCachePath, blobCacheSuffixedPath, imageDisk, layerDisk}

for _, f := range stuffs {
err := os.Remove(f)
Expand Down

0 comments on commit 3a98b05

Please sign in to comment.