From 6176626ca16cb25125472b7dd62df1fb6bfa287a Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Fri, 21 Feb 2020 23:18:31 -0300 Subject: [PATCH 1/2] Update changelog --- CHANGELOG.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8232e3b..c701bea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,29 @@ +## 2020-02-02, Version 1.0.0 +### Commits +- [[`3de8d37a0c`](https://github.com/datrs/random-access-disk/commit/3de8d37a0c33bc15874de8870734bbdd07a8b24c)] 1.0.0 (substack) +- [[`2fca3428a6`](https://github.com/datrs/random-access-disk/commit/2fca3428a6ca6e484c5b31c8b62422553641731e)] Merge pull request #28 from bltavares/bump-deps (Szabolcs Berecz) +- [[`bebe8b4a2c`](https://github.com/datrs/random-access-disk/commit/bebe8b4a2c95dcd6d19c54ceb2fe854799af4ea4)] Update code to editio 2018 (Bruno Tavares) +- [[`310dd8a5d7`](https://github.com/datrs/random-access-disk/commit/310dd8a5d79e2edcfbded8cb48a17c5949c6b276)] Bump random-access-storage to 3.0.0 (Bruno Tavares) +- [[`95c3dad271`](https://github.com/datrs/random-access-disk/commit/95c3dad2715ade75c18337bb72f109573c9c08e3)] updated to use u64 (substack) +- [[`1d884a4432`](https://github.com/datrs/random-access-disk/commit/1d884a443232528c2a0a9e03901cb12eca137ac1)] sync_all implementation (substack) +- [[`bd9d0f6a86`](https://github.com/datrs/random-access-disk/commit/bd9d0f6a869d9f8225ae8582a5bfe5db6ca52578)] Update mkdirp requirement from 0.1.0 to 1.0.0 (dependabot-preview[bot]) +- [[`f9b34735e7`](https://github.com/datrs/random-access-disk/commit/f9b34735e79020ff2f39bef510026f5cf8bf02b3)] Update quickcheck requirement from 0.7.2 to 0.8.0 (dependabot[bot]) +- [[`4785a3dfa5`](https://github.com/datrs/random-access-disk/commit/4785a3dfa5aed164df833eafaeef4edda0dfd2c4)] Update changelog (Yoshua Wuyts) + +### Stats +```diff + CHANGELOG.md | 16 ++++++- + Cargo.toml | 25 ++++----- + fuzz/Cargo.toml | 1 +- + fuzz/fuzz_targets/fuzz_target_1.rs | 6 +-- + src/lib.rs | 109 ++++++++++++++++++++++++-------------- + tests/model.rs | 34 ++++-------- + tests/regression.rs | 5 +-- + tests/test.rs | 82 +++++++++++++++++++++++++++-- + 8 files changed, 194 insertions(+), 84 deletions(-) +``` + + ## 2018-12-20, Version 0.8.0 ### Commits - [[`c7cdc2d39a`](https://github.com/datrs/random-access-disk/commit/c7cdc2d39a7d92103f7125c28d2451ecf6272578)] (cargo-release) version 0.8.0 (Yoshua Wuyts) From e64ce5525b84aa19915cdc066d0f2b8151b0b8ed Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Wed, 26 Feb 2020 14:38:59 -0300 Subject: [PATCH 2/2] Move from failure to use stderr Related to https://github.com/datrs/hypercore/issues/101 --- Cargo.toml | 2 +- src/lib.rs | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8193334..f3d7753 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ version = "1.0.0" edition = "2018" [dependencies] -failure = "0.1.6" +anyhow = "1.0.26" mkdirp = "1.0.0" random-access-storage = "3.0.0" diff --git a/src/lib.rs b/src/lib.rs index d4c1428..9561b24 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,7 @@ #![cfg_attr(feature = "nightly", doc(include = "../README.md"))] #![cfg_attr(test, deny(warnings))] -use failure::{ensure, Error}; +use anyhow::{anyhow, Error}; use random_access_storage::RandomAccess; use std::fs::{self, OpenOptions}; use std::io::{Read, Seek, SeekFrom, Write}; @@ -31,7 +31,7 @@ impl RandomAccessDisk { } impl RandomAccess for RandomAccessDisk { - type Error = Error; + type Error = Box; fn write(&mut self, offset: u64, data: &[u8]) -> Result<(), Self::Error> { let mut file = self.file.as_ref().expect("self.file was None."); @@ -59,15 +59,17 @@ impl RandomAccess for RandomAccessDisk { // reflect the state of the world. // #[cfg_attr(test, allow(unused_io_amount))] fn read(&mut self, offset: u64, length: u64) -> Result, Self::Error> { - ensure!( - (offset + length) as u64 <= self.length, - format!( - "Read bounds exceeded. {} < {}..{}", - self.length, - offset, - offset + length - ) - ); + if (offset + length) as u64 > self.length { + return Err( + anyhow!( + "Read bounds exceeded. {} < {}..{}", + self.length, + offset, + offset + length + ) + .into(), + ); + } let mut file = self.file.as_ref().expect("self.file was None."); let mut buffer = vec![0; length as usize];