MCPcopy Index your code
hub / github.com/cloudfoundry/cli / removeOldTempConfigFiles

Function removeOldTempConfigFiles

util/configv3/load_config.go:181–207  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

179}
180
181func removeOldTempConfigFiles() error {
182 oldTempFileNames, err := filepath.Glob(filepath.Join(configDirectory(), "temp-config?*"))
183 if err != nil {
184 return err
185 }
186
187 for _, oldTempFileName := range oldTempFileNames {
188 fi, err := os.Lstat(oldTempFileName)
189 if err != nil {
190 // ignore if file doesn't exist anymore due to race conditions if multiple cli commands are running in parallel
191 if errors.Is(err, os.ErrNotExist) {
192 continue
193 }
194 return err
195 }
196 // only delete old orphans which are not caught by the signal handler in WriteConfig
197 if fi.ModTime().After(time.Now().Add(-5 * time.Minute)) {
198 continue
199 }
200 err = os.Remove(oldTempFileName)
201 if err != nil && !errors.Is(err, os.ErrNotExist) {
202 return err
203 }
204 }
205
206 return nil
207}

Callers 1

LoadConfigFunction · 0.85

Calls 4

ModTimeMethod · 0.80
configDirectoryFunction · 0.70
AddMethod · 0.65
NowMethod · 0.65

Tested by

no test coverage detected