Skip to content

Commit 566cb63

Browse files
sirnodims
authored andcommitted
Relay os.ErrNotExists when both containers.json and volatile-containers.json do not exist.
1 parent 83b03e1 commit 566cb63

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

container/podman/fs.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ type containersJSON struct {
3838

3939
func rwLayerID(storageDriver docker.StorageDriver, storageDir string, containerID string) (string, error) {
4040
var containers []containersJSON
41+
fileExists := false
4142

4243
for _, filename := range containersJsonFilnames {
4344
data, err := os.ReadFile(filepath.Join(storageDir, string(storageDriver)+"-containers", filename))
@@ -46,6 +47,7 @@ func rwLayerID(storageDriver docker.StorageDriver, storageDir string, containerI
4647
}
4748

4849
if data != nil {
50+
fileExists = true
4951
var buffer []containersJSON
5052
err = json.Unmarshal(data, &buffer)
5153
if err != nil {
@@ -55,8 +57,8 @@ func rwLayerID(storageDriver docker.StorageDriver, storageDir string, containerI
5557
}
5658
}
5759

58-
if len(containers) == 0 {
59-
return "", fmt.Errorf("no containers found in containers.json or volatile-containers.json in %q", filepath.Join(storageDir, string(storageDriver)+"-containers"))
60+
if !fileExists {
61+
return "", os.ErrNotExist
6062
}
6163

6264
for _, c := range containers {

0 commit comments

Comments
 (0)