instead of os.rename, io.WriteFile and os.Remove
This commit is contained in:
15
cmd/main.go
15
cmd/main.go
@@ -68,7 +68,20 @@ func merge(filepath string, mergeTargetFilePath string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return os.Rename(tmppath, filepath)
|
||||
return rename(tmppath, filepath)
|
||||
}
|
||||
|
||||
func rename(oldpath, newpath string) error {
|
||||
b, err := io.ReadFile(oldpath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := io.WriteFile(b, newpath, os.ModePerm); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return os.Remove(oldpath)
|
||||
}
|
||||
|
||||
func marshalRootToTempFile(root pttodo.Root) (string, error) {
|
||||
|
||||
Reference in New Issue
Block a user