diff options
author | sasha-s <sasha@scaledinference.com> | 2015-05-18 12:00:40 -0700 |
---|---|---|
committer | sasha-s <sasha@scaledinference.com> | 2015-05-18 12:00:40 -0700 |
commit | aa13f7f94f882fa0964b801c062217c0b9a45436 (patch) | |
tree | 81bfb561bafd5be1c96768e3474ce88558614ad5 /bolt_windows.go | |
parent | use a shared lock in read-only mode (diff) | |
download | dedo-aa13f7f94f882fa0964b801c062217c0b9a45436.tar.gz dedo-aa13f7f94f882fa0964b801c062217c0b9a45436.tar.xz |
make ignoring Truncate() explicit
https://github.com/boltdb/bolt/pull/371#issuecomment-103176330
Diffstat (limited to 'bolt_windows.go')
-rw-r--r-- | bolt_windows.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/bolt_windows.go b/bolt_windows.go index 783b633..8b782be 100644 --- a/bolt_windows.go +++ b/bolt_windows.go @@ -28,9 +28,11 @@ func funlock(f *os.File) error { // mmap memory maps a DB's data file. // Based on: https://github.com/edsrzf/mmap-go func mmap(db *DB, sz int) error { - // Truncate the database to the size of the mmap. - if err := db.ops.Truncate(int64(sz)); err != nil { - return fmt.Errorf("truncate: %s", err) + if !db.readOnly { + // Truncate the database to the size of the mmap. + if err := db.file.Truncate(int64(sz)); err != nil { + return fmt.Errorf("truncate: %s", err) + } } // Open a file mapping handle. |