Browse Source

Merge pull request #189 from mohanson/patch-2

bug fix: WriteFileAtomic
pull/1780/head
Ethan Buchman 7 years ago
committed by GitHub
parent
commit
f664b020cd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions
  1. +3
    -0
      common/os.go

+ 3
- 0
common/os.go View File

@ -148,6 +148,9 @@ func WriteFileAtomic(filename string, data []byte, perm os.FileMode) error {
} else if n < len(data) {
return io.ErrShortWrite
}
// Close the file before renaming it, otherwise it will cause "The process
// cannot access the file because it is being used by another process." on windows.
f.Close()
return os.Rename(f.Name(), filename)
}


Loading…
Cancel
Save