Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit ee595b0

Browse files
committed
Ignore unknown files on image ls
When a user opens the bundles directory with Finder it will add the junk file .DS_Store, this makes docker app image ls fail. With this change we silently ignore unknown files in the bundle store. Signed-off-by: Djordje Lukic <[email protected]>
1 parent 98cd1c5 commit ee595b0

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

internal/store/bundle.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (b *bundleStore) List() ([]reference.Named, error) {
7575
}
7676

7777
if !strings.HasSuffix(info.Name(), ".json") {
78-
return fmt.Errorf("unknown file %q in bundle store", path)
78+
return nil
7979
}
8080

8181
ref, err := b.pathToReference(path)

internal/store/bundle_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package store
22

33
import (
44
"os"
5+
"path"
56
"path/filepath"
67
"testing"
78

@@ -232,4 +233,14 @@ func TestList(t *testing.T) {
232233
assert.Equal(t, bundles[0].String(), "docker.io/my-repo/a-bundle:my-tag")
233234
assert.Equal(t, bundles[1].String(), "docker.io/my-repo/b-bundle@sha256:"+testSha)
234235
})
236+
237+
t.Run("Ignores unknown files in the bundle store", func(t *testing.T) {
238+
p := path.Join(dockerConfigDir.Path(), AppConfigDirectory, BundleStoreDirectory)
239+
//nolint:errcheck
240+
os.OpenFile(path.Join(p, "filename"), os.O_CREATE, 06444)
241+
242+
bundles, err := bundleStore.List()
243+
assert.NilError(t, err)
244+
assert.Equal(t, len(bundles), 2)
245+
})
235246
}

0 commit comments

Comments
 (0)