Fixes: https://github.com/zkat/cacache-rs/issues/48
This avoids SIGBUS on memory write in case the temp file is sparse.
Implemented for linux only; other target_os cfg values unchanged.
This PR is based on the work @alexschrod did in PR #29. All
I did was carry it over the finish line.
This PR adds a feature to the crate named `tokio-runtime`. If
you disable default features and enable this new one, cacache
uses tokio as its async executor. This makes integrating cacache
with tokio-using projects easier, because the file types leak out
if you use anything more than the top-level convenience functions.
The PR implements the feature using shims in a new submodule named
`async_lib`. This module conditionally uses either async-std
or tokio based on feature selection, and hides some differences with
convenience functions.
This change should not be a breaking change, because the default is
still async-std.
There are a few other small changes in this PR worth noting.
- The README shows how to switch runtimes.
- There's a justfile to run common tasks, including those in makefile.toml.
The default shell is `sh`, so this might not work out of the box for
Windows users.
- The tests can now run under either runtime. The justfile has a recipe
that runs them both.
- The benchmarks can also run under either runtime. The justfile has two
recipe for this, one using bench and the other using criterion's runner.
- The dependencies now pull in async-attributes by default along with
async-std. This made it easier to swap runtimes in the tests.
- All dependency versions have been bumped.
Co-authored-by: @alexschrod
Fixes: https://github.com/zkat/cacache-rs/issues/34
The async `poll_write()` implementation was creating a tempfile as
a backing for its inner mmap, but it was failing to set the length
on the file to match the incoming data. Compare with the sync
implementation!
This bug was exposed when the `memmap2` crate was swapped in
for `memmap`. The older crate was likely more lax about this.
Wrote a pair of new tests for `cacache::write_hash_sync` and
`cacache::write_hash`. The async test fails without this change, as
does any benchmarks run. Everything passes with it.
BREAKING CHANGE: This commit also bumps the MSRV for cacache to 1.66.1.
Co-authored-by: Florian Albertz <git@albertz.io>
BREAKING CHANGE: This changes the exported error type(s) for cacache, making it way easier to do error handling when something goes kaput.
Before this change the public interface wouldn't allow downstream users
to use the actual items since it wasn't communicated on the function
signature.
Previously a user would run into errors like this:
> no field `key` on type `<impl std::iter::Iterator as std::iter::Iterator>::Item`
Fixes: #16
BREAKING CHANGE: If you were relying on the chown functionality for the index (which you probably weren't), then your index will no longer be updated that way.
Fixes: #13
BREAKING CHANGE: The entire API surface has been rewritten and overhauled. Instead of breaking up the package into get/put/rm/ls modules, everything is now available mostly through the toplevel module, following the same conventions as std:fs for its operations. Associated structs and other types have also been renamed. Please refer to the documentation for the new API, and I hope you find it more ergonomic!
Fixes: #19
BREAKING CHANGE: Error values have changed. If you were inspecting or
matching against actual return values, you'll need to change your code
to use the new enums.
BREAKING CHANGE: the async_* namespaces are gone, and all the previously-sync APIs (get::data, put::data, etc), are all suffixed with _sync now. You'll need to adjust your usage accordingly.