MCPcopy
hub / github.com/keploy/keploy / DeleteFileIfNotExists

Function DeleteFileIfNotExists

utils/utils.go:332–350  ·  view source on GitHub ↗
(logger *zap.Logger, name string)

Source from the content-addressed store, hash-verified

330}
331
332func DeleteFileIfNotExists(logger *zap.Logger, name string) (err error) {
333 //Check if file exists
334 _, err = os.Stat(name)
335 if os.IsNotExist(err) {
336 return nil
337 }
338 //If it does, remove it.
339 err = os.Remove(name)
340 if err != nil {
341 if runtime.GOOS == "windows" && strings.Contains(strings.ToLower(err.Error()), "used by another process") {
342 logger.Debug("skipping removal of file still in use during shutdown", zap.String("file", name), zap.Error(err))
343 return nil
344 }
345 LogError(logger, err, "Error removing file")
346 return err
347 }
348
349 return nil
350}
351
352type GitHubRelease struct {
353 TagName string `json:"tag_name"`

Callers 1

startFunction · 0.92

Calls 4

LogErrorFunction · 0.85
DebugMethod · 0.65
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected