Remove removes the shutdown marker file on the given path if it exists.
(p string)
| 26 | |
| 27 | // Remove removes the shutdown marker file on the given path if it exists. |
| 28 | func Remove(p string) error { |
| 29 | err := os.Remove(p) |
| 30 | if err != nil && !os.IsNotExist(err) { |
| 31 | return err |
| 32 | } |
| 33 | |
| 34 | dir, err := os.OpenFile(path.Dir(p), os.O_RDONLY, 0o600) // mode doesn't matter since we're not passing os.O_CREATE |
| 35 | if err != nil { |
| 36 | return err |
| 37 | } |
| 38 | |
| 39 | merr := multierror.New() |
| 40 | merr.Add(dir.Sync()) |
| 41 | merr.Add(dir.Close()) |
| 42 | return merr.Err() |
| 43 | } |
| 44 | |
| 45 | // Exists returns true if the shutdown marker file exists on the given path, false otherwise |
| 46 | func Exists(p string) (bool, error) { |
no test coverage detected