mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-09-20 02:57:19 +03:00
Ensure permissions are correct when using atomic writes
This commit is contained in:
parent
e555d963b1
commit
0a985134e2
@ -121,6 +121,15 @@ func (self *Output) commit() {
|
||||
} else {
|
||||
self.dest.Close()
|
||||
if !self.is_stream {
|
||||
f, err := os.Create(self.arg)
|
||||
if err == nil {
|
||||
fi, err := f.Stat()
|
||||
if err == nil {
|
||||
self.dest.Chmod(fi.Mode().Perm())
|
||||
}
|
||||
f.Close()
|
||||
os.Remove(f.Name())
|
||||
}
|
||||
self.err = os.Rename(self.dest.Name(), self.arg)
|
||||
if self.err != nil {
|
||||
os.Remove(self.dest.Name())
|
||||
|
Loading…
Reference in New Issue
Block a user