aboutsummaryrefslogtreecommitdiff
path: root/internal/configfile
diff options
context:
space:
mode:
authorJakob Unterwurzacher2019-04-07 22:04:21 +0200
committerJakob Unterwurzacher2019-04-08 19:54:54 +0200
commit8459bb15c1a32561c250a8b688ab4a7ecda0a4aa (patch)
tree2308c6463c0a5af3bb6f9025d61876beed4f0dba /internal/configfile
parent7d1400d872c6e0c640ed6279903df746adec332b (diff)
configfile: fall back to sync() if fsync() fails
This can happen on network drives: FRITZ.NAS mounted on MacOS returns "operation not supported": https://github.com/rfjakob/gocryptfs/issues/390
Diffstat (limited to 'internal/configfile')
-rw-r--r--internal/configfile/config_file.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/internal/configfile/config_file.go b/internal/configfile/config_file.go
index c6c6e6d..e93affd 100644
--- a/internal/configfile/config_file.go
+++ b/internal/configfile/config_file.go
@@ -8,6 +8,7 @@ import (
"io"
"io/ioutil"
"log"
+ "syscall"
"github.com/rfjakob/gocryptfs/internal/contentenc"
"github.com/rfjakob/gocryptfs/internal/cryptocore"
@@ -285,7 +286,11 @@ func (cf *ConfFile) WriteFile() error {
}
err = fd.Sync()
if err != nil {
- return err
+ // This can happen on network drives: FRITZ.NAS mounted on MacOS returns
+ // "operation not supported": https://github.com/rfjakob/gocryptfs/issues/390
+ tlog.Warn.Printf("Warning: fsync failed: %v", err)
+ // Try sync instead
+ syscall.Sync()
}
err = fd.Close()
if err != nil {