Merge pull request #54 from tendermint/develop

common: WriteFileAtomic use tempfile in current dir
This commit is contained in:
Ethan Buchman 2017-09-22 13:23:12 -04:00 committed by GitHub
commit 9997e3a3b4
3 changed files with 10 additions and 2 deletions

View File

@ -1,5 +1,11 @@
# Changelog # Changelog
## 0.3.1 (September 22, 2017)
BUG FIXES:
- [common] fix WriteFileAtomic to not use /tmp, which can be on another device
## 0.3.0 (September 22, 2017) ## 0.3.0 (September 22, 2017)
BREAKING CHANGES: BREAKING CHANGES:

View File

@ -7,6 +7,7 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"os/signal" "os/signal"
"path/filepath"
"strings" "strings"
) )
@ -101,7 +102,8 @@ func MustWriteFile(filePath string, contents []byte, mode os.FileMode) {
// WriteFileAtomic writes newBytes to temp and atomically moves to filePath // WriteFileAtomic writes newBytes to temp and atomically moves to filePath
// when everything else succeeds. // when everything else succeeds.
func WriteFileAtomic(filePath string, newBytes []byte, mode os.FileMode) error { func WriteFileAtomic(filePath string, newBytes []byte, mode os.FileMode) error {
f, err := ioutil.TempFile("", "") dir := filepath.Dir(filePath)
f, err := ioutil.TempFile(dir, "")
if err != nil { if err != nil {
return err return err
} }

View File

@ -1,3 +1,3 @@
package version package version
const Version = "0.3.0" const Version = "0.3.1"