Fix issues related to #239
Disable mmap reader for current datafile, which only read from the fd.
Co-authored-by: jason3gb <jason3gb@gmail.com>
Reviewed-on: https://git.mills.io/prologic/bitcask/pulls/240
Reviewed-by: James Mills <james@mills.io>
Reviewed-by: Tai Groot <tai@taigrr.com>
Co-authored-by: jason3gb <jason3gb@noreply@mills.io>
Co-committed-by: jason3gb <jason3gb@noreply@mills.io>
* Add configuration options for FileMode
Add two additional configuration values, and their corresponding default values:
* DirFileModeBeforeUmask - Dir FileMode is used on all directories created. DefaultDirFileModeBeforeUmask is 0700.
* FileFileModeBeforeUmask - File FileMode is used on all files created, except for the "lock" file (managed by the Flock library). DefaultFileFileModeBeforeUmask is 0600.
When using these bits of configuration, keep in mind these FileMode values are set BEFORE any umask rules are applied. For example, if the user's umask is 022, setting DirFileFileModeBeforeUmask to 777 will result in directories with FileMode set to 755 (this umask prevents the write bit from being applied to group and world permissions).
* moving defer statements after checking for errors
use os.ModePerm const instead of os.FileMode(777)
* fix spelling/grammar
* skip these tests for Windows as they appear to break - Windows is less POSIX-y than it claims
* ignore "lock" file for default case too -- this was incorrectly passing before including this, as my local dev station has umask 022
* internal/data: move codec to own subpackage
* internal/data/codec: check & test nil Entry Decode
* internal/data/decoder: test for short prefix error
* internal/data/codec: test invalid key & value sizes
* internal/data/codec: check & test for truncated data
* interna/data/codec: use assert for tests
* internal/data: comment exported functions
* internal/data: make smaller codec exported api surface
* make key and value sizes serializing bubble up to everything
* Makefile setup & go mod tidy
* Add Unit Test for testing a corrupted config
* Add Unit Test for testing errors from .Stats()
* Refactor Datafile into an interface and add Unit Tests for testing Merge() errors
* Refactor indexer into an interface and add Unit Tests for .Close() errors
* Add Unit Tests for .Delete() errors
* Add Unit Tests for testing Put/Get errors
* Add Unit Test for testing Open errors (bad path for example)
* Refactor out bitcask.writeConfig
* Add more tests for config errors
* Add unit test for options that might error
* Add more test cases for close errors
* Add test case for rotating datafiles
* Fix a possible data race in .Stats()
* Add test case for checksum errors
* Add test case for Sync errors with Put and WithSync enabled
* Refactor and use testify.mock for mocks and generate mocks for all interfaces
* Refactor TestCloseErrors
* Refactored TestDeleteErrors
* Refactored TestGetErrors
* Refactored TestPutErrors
* Refactored TestMergeErrors and fixed a bug with .Fold()
* Add test case for Scan() errors
* Apparently only Scan() can return nil Node()s?