From aa13f7f94f882fa0964b801c062217c0b9a45436 Mon Sep 17 00:00:00 2001 From: sasha-s Date: Mon, 18 May 2015 12:00:40 -0700 Subject: make ignoring Truncate() explicit https://github.com/boltdb/bolt/pull/371#issuecomment-103176330 --- bolt_windows.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'bolt_windows.go') 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. -- cgit v1.2.3