Skip to content

Commit b3004ae

Browse files
authored
Merge pull request lxc#476 from stgraber/main
image-publisher: Handle missing manifests
2 parents 1902db7 + c486a69 commit b3004ae

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

incus-osd/cmd/image-publisher/changelog.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,22 +100,24 @@ func generateChangelog(metaUpdate *apiupdate.Update, channel string, targetPath
100100

101101
// #nosec G304
102102
priorManifestFileGz, err := os.Open(filepath.Join(targetPath, "../", priorVersion, priorFilename))
103-
if err != nil {
103+
if err != nil && !os.IsNotExist(err) {
104104
return err
105105
}
106106

107-
defer func() { _ = priorManifestFileGz.Close() }() //nolint:revive
107+
if err == nil {
108+
defer func() { _ = priorManifestFileGz.Close() }() //nolint:revive
108109

109-
priorManifestFile, err := gzip.NewReader(priorManifestFileGz)
110-
if err != nil {
111-
return err
112-
}
110+
priorManifestFile, err := gzip.NewReader(priorManifestFileGz)
111+
if err != nil {
112+
return err
113+
}
113114

114-
defer func() { _ = priorManifestFile.Close() }() //nolint:revive
115+
defer func() { _ = priorManifestFile.Close() }() //nolint:revive
115116

116-
err = json.NewDecoder(priorManifestFile).Decode(&priorManifest)
117-
if err != nil {
118-
return err
117+
err = json.NewDecoder(priorManifestFile).Decode(&priorManifest)
118+
if err != nil {
119+
return err
120+
}
119121
}
120122
}
121123

0 commit comments

Comments
 (0)