aboutsummaryrefslogtreecommitdiff
path: root/bolt_windows.go
diff options
context:
space:
mode:
Diffstat (limited to 'bolt_windows.go')
-rw-r--r--bolt_windows.go8
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.