We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 079c926 + dee646a commit 52d37feCopy full SHA for 52d37fe
pkg/api/cache.go
@@ -181,16 +181,22 @@ func (c *ScalewayCache) Save() error {
181
logrus.Debugf("Writing cache file to disk")
182
183
if c.Modified {
184
- file, err := ioutil.TempFile("", "")
+ file, err := ioutil.TempFile(filepath.Dir(c.Path), filepath.Base(c.Path))
185
if err != nil {
186
return err
187
}
188
+ defer file.Close()
189
encoder := json.NewEncoder(file)
190
err = encoder.Encode(*c)
191
192
+ os.Remove(file.Name())
193
+ return err
194
+ }
195
+
196
+ if err := os.Rename(file.Name(), c.Path); err != nil {
197
198
199
- return os.Rename(file.Name(), c.Path)
200
201
return nil
202
0 commit comments