refactor(cli): rename operator command to tht
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
//go:build !windows
|
||||
|
||||
package pi
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// durableReplace acknowledges both the data file and its directory entry. A successful return
|
||||
// is the strongest atomic replacement guarantee supported by Unix filesystems.
|
||||
func durableReplace(temporary, target, directory string) error {
|
||||
if err := os.Rename(temporary, target); err != nil {
|
||||
return err
|
||||
}
|
||||
dir, err := os.Open(directory)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer dir.Close()
|
||||
return dir.Sync()
|
||||
}
|
||||
|
||||
func durableRemove(path string) error {
|
||||
if err := os.Remove(path); err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
return err
|
||||
}
|
||||
dir, err := os.Open(filepath.Dir(path))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer dir.Close()
|
||||
return dir.Sync()
|
||||
}
|
||||
Reference in New Issue
Block a user