aboutsummaryrefslogtreecommitdiff
path: root/bolt_unix.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2015-05-06 09:24:37 -0600
committerBen Johnson <benbjohnson@yahoo.com>2015-05-06 09:24:37 -0600
commitfd65d6c95495fc58156e9407ad15e3e43dc961f8 (patch)
tree1925b67efdf686f9bdda49f47a278d8544a67aa9 /bolt_unix.go
parentMerge pull request #354 from xiang90/cmd (diff)
parentAdd DB.NoGrowSync flag. (diff)
downloaddedo-fd65d6c95495fc58156e9407ad15e3e43dc961f8.tar.gz
dedo-fd65d6c95495fc58156e9407ad15e3e43dc961f8.tar.xz
Merge pull request #363 from benbjohnson/no-truncate
Add DB.NoTruncate flag.
Diffstat (limited to 'bolt_unix.go')
-rw-r--r--bolt_unix.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/bolt_unix.go b/bolt_unix.go
index e222cfd..35dce08 100644
--- a/bolt_unix.go
+++ b/bolt_unix.go
@@ -44,11 +44,13 @@ func funlock(f *os.File) error {
func mmap(db *DB, sz int) error {
// Truncate and fsync to ensure file size metadata is flushed.
// https://github.com/boltdb/bolt/issues/284
- if err := db.file.Truncate(int64(sz)); err != nil {
- return fmt.Errorf("file resize error: %s", err)
- }
- if err := db.file.Sync(); err != nil {
- return fmt.Errorf("file sync error: %s", err)
+ if !db.NoGrowSync {
+ if err := db.file.Truncate(int64(sz)); err != nil {
+ return fmt.Errorf("file resize error: %s", err)
+ }
+ if err := db.file.Sync(); err != nil {
+ return fmt.Errorf("file sync error: %s", err)
+ }
}
// Map the data file to memory.