diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index e01402e..99814bb 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -3,7 +3,7 @@ name: build on: [push] env: - LIBSODIUM: libsodium-1.0.17 + LIBSODIUM: libsodium-1.0.18 jobs: build-linux: @@ -16,8 +16,8 @@ jobs: id: cache-libsodium uses: actions/cache@v1 with: - path: libsodium-1.0.17 - key: ${{ runner.os }}-libsodium-1.0.17 + path: libsodium-1.0.18 + key: ${{ runner.os }}-libsodium-1.0.18 - name: Build libsodium if: steps.cache-libsodium.outputs.cache-hit != 'true' @@ -37,29 +37,29 @@ jobs: - name: Run ZboxFS file storage tests run: cargo test --features storage-file - + build-win: runs-on: windows-latest env: - SODIUM_LIB_DIR: libsodium-1.0.17\x64\Release\v141\static + SODIUM_LIB_DIR: libsodium-1.0.18\x64\Release\v141\static SODIUM_STATIC: 1 - + steps: - uses: actions/checkout@v1 - + - name: Cache libsodium id: cache-libsodium uses: actions/cache@v1 with: - path: libsodium-1.0.17 - key: ${{ runner.os }}-libsodium-1.0.17 - + path: libsodium-1.0.18 + key: ${{ runner.os }}-libsodium-1.0.18 + - name: Download libsodium if: steps.cache-libsodium.outputs.cache-hit != 'true' run: | Invoke-WebRequest https://download.libsodium.org/libsodium/releases/${env:LIBSODIUM}-msvc.zip -OutFile ${env:LIBSODIUM}-msvc.zip Expand-Archive ${env:LIBSODIUM}-msvc.zip -DestinationPath ${env:LIBSODIUM} - + - name: Build ZboxFS run: cargo build diff --git a/Cargo.toml b/Cargo.toml index fa4fbe4..3d9d1eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zbox" -version = "0.9.1" +version = "0.9.2" authors = ["Bo Lu"] description = "ZboxFS is a zero-details, privacy-focused in-app file system." documentation = "https://docs.rs/zbox" @@ -67,21 +67,21 @@ libsodium-bundled = [] docs-rs = [] [dependencies] -cfg-if = "0.1.10" -env_logger = "0.7.1" -log = "0.4.8" -rmp-serde = "0.14.0" -serde = "1.0.104" -serde_derive = "1.0.104" +cfg-if = "1.0.0" +env_logger = "0.9.0" +log = "0.4.14" +rmp-serde = "0.15.5" +serde = "1.0.130" +serde_derive = "1.0.130" lazy_static = "1.4.0" -libsqlite3-sys = { version = "0.16.0", optional = true } -redis = { version = "0.11.0", optional = true } -http = { version = "0.1.17", optional = true } -serde_json = { version = "1.0.39", optional = true } +libsqlite3-sys = { version = "0.22.2", optional = true } +redis = { version = "0.21.2", optional = true } +http = { version = "0.2.4", optional = true } +serde_json = { version = "1.0.67", optional = true } reqwest = { version = "0.9.18", default-features = false, features = [ "rustls-tls" ], optional = true } [dependencies.linked-hash-map] -version = "0.5.2" +version = "0.5.4" features = ["serde_impl"] [target.'cfg(target_os = "android")'.dependencies] @@ -93,14 +93,14 @@ js-sys = { version = "0.3.27" } web-sys = { version = "0.3.27", features = [ "Crypto", "WorkerGlobalScope", "XmlHttpRequest", "XmlHttpRequestResponseType", "Blob"] } [dev-dependencies] -bytes = "0.4.12" +bytes = "1.1.0" tempdir = "0.3.7" -rand = "0.6.5" -rand_xorshift = "0.1.1" +rand = "0.8.4" +rand_xorshift = "0.3.0" [build-dependencies] -pkg-config = "0.3.14" -cc = "1.0.45" +pkg-config = "0.3.19" +cc = "1.0.70" [target.'cfg(target_os = "windows")'.build-dependencies] libflate = "0.1" diff --git a/README.md b/README.md index f86ed41..7eda3db 100644 --- a/README.md +++ b/README.md @@ -192,7 +192,7 @@ Add the following dependency to your `Cargo.toml`: ```toml [dependencies] -zbox = "0.9.1" +zbox = "0.9.2" ``` If you don't want to install libsodium by yourself, simply specify @@ -201,7 +201,7 @@ verify and build libsodium. ```toml [dependencies] -zbox = { version = "0.9.1", features = ["libsodium-bundled"] } +zbox = { version = "0.9.2", features = ["libsodium-bundled"] } ``` ## Example diff --git a/build.rs b/build.rs index 0179b52..153336f 100644 --- a/build.rs +++ b/build.rs @@ -14,10 +14,10 @@ use std::path::PathBuf; use std::process::Command; #[cfg(all(feature = "libsodium-bundled", not(target_os = "windows")))] -const LIBSODIUM_NAME: &'static str = "libsodium-1.0.17"; +const LIBSODIUM_NAME: &'static str = "libsodium-1.0.18"; #[cfg(all(feature = "libsodium-bundled", not(target_os = "windows")))] const LIBSODIUM_URL: &'static str = - "https://download.libsodium.org/libsodium/releases/libsodium-1.0.17.tar.gz"; + "https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz"; // skip the build script when building doc on docs.rs #[cfg(feature = "docs-rs")] @@ -51,7 +51,7 @@ fn main() { // under '/usr' dir, in that case use the environment variables // mentioned above pkg_config::Config::new() - .atleast_version("1.0.17") + .atleast_version("1.0.18") .statik(true) .probe("libsodium") .unwrap(); @@ -213,9 +213,9 @@ fn download_and_install_libsodium() { use std::io; use std::path::PathBuf; #[cfg(target_env = "msvc")] - static LIBSODIUM_ZIP: &'static str = "https://download.libsodium.org/libsodium/releases/libsodium-1.0.17-msvc.zip"; + static LIBSODIUM_ZIP: &'static str = "https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-msvc.zip"; #[cfg(target_env = "mingw")] - static LIBSODIUM_ZIP: &'static str = "https://download.libsodium.org/libsodium/releases/libsodium-1.0.17-mingw.tar.gz"; + static LIBSODIUM_ZIP: &'static str = "https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-mingw.tar.gz"; let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); let sodium_lib_dir = out_dir.join("libsodium"); if !sodium_lib_dir.exists() { @@ -269,7 +269,7 @@ fn download_and_install_libsodium() { use std::io; use std::path::PathBuf; use tar::Archive; - static LIBSODIUM_ZIP: &'static str = "https://download.libsodium.org/libsodium/releases/libsodium-1.0.17-mingw.tar.gz"; + static LIBSODIUM_ZIP: &'static str = "https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-mingw.tar.gz"; let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); let sodium_lib_dir = out_dir.join("libsodium"); if !sodium_lib_dir.exists() { diff --git a/src/base/mod.rs b/src/base/mod.rs index de6cac7..1ccfcde 100644 --- a/src/base/mod.rs +++ b/src/base/mod.rs @@ -30,7 +30,7 @@ use env_logger; /// Get ZboxFS library version string. /// -/// This method return ZboxFS library version as a string, e.g. "ZboxFS v0.9.1". +/// This method return ZboxFS library version as a string, e.g. "ZboxFS v0.9.2". #[inline] pub fn zbox_version() -> String { format!("ZboxFS v{}", Version::lib_version()) diff --git a/src/content/content.rs b/src/content/content.rs index 6aedfad..2554262 100644 --- a/src/content/content.rs +++ b/src/content/content.rs @@ -1,5 +1,4 @@ use std::cmp::min; -use std::error::Error as StdError; use std::fmt::{self, Debug}; use std::io::{ Error as IoError, ErrorKind, Read, Result as IoResult, Seek, SeekFrom, diff --git a/src/content/segment.rs b/src/content/segment.rs index dea5a4c..c6b21b9 100644 --- a/src/content/segment.rs +++ b/src/content/segment.rs @@ -1,4 +1,3 @@ -use std::error::Error as StdError; use std::fmt::{self, Debug}; use std::io::{Error as IoError, ErrorKind, Read, Result as IoResult, Write}; use std::ops::{Index, IndexMut, Range}; diff --git a/src/error.rs b/src/error.rs index b227bdb..970afd0 100644 --- a/src/error.rs +++ b/src/error.rs @@ -191,86 +191,7 @@ impl Display for Error { } impl StdError for Error { - fn description(&self) -> &str { - match *self { - Error::RefOverflow => "Refcnt overflow", - Error::RefUnderflow => "Refcnt underflow", - - Error::InitCrypto => "Initialise crypto error", - Error::NoAesHardware => "No AES hardware", - Error::Hashing => "Hashing out of memory", - Error::InvalidCost => "Invalid cost", - Error::InvalidCipher => "Invalid cipher", - Error::Encrypt => "Encrypt error", - Error::Decrypt => "Decrypt error", - - Error::InvalidUri => "Invalid Uri", - Error::InvalidSuperBlk => "Invalid super block", - Error::Corrupted => "Volume is corrupted", - Error::WrongVersion => "Version not match", - Error::NoEntity => "Entity not found", - Error::NotInSync => "Repo is not in sync", - Error::RepoOpened => "Repo is opened", - Error::RepoClosed => "Repo is closed", - Error::RepoExists => "Repo already exists", - - Error::InTrans => "Already in transaction", - Error::NotInTrans => "Not in transaction", - Error::NoTrans => "Transaction not found", - Error::Uncompleted => "Transaction uncompleted", - Error::InUse => "Entity is in use", - - Error::NoContent => "Content not found", - - Error::InvalidArgument => "Invalid argument", - Error::InvalidPath => "Invalid path", - Error::NotFound => "File not found", - Error::AlreadyExists => "File already exists", - Error::IsRoot => "File is root", - Error::IsDir => "Path is dir", - Error::IsFile => "Path is file", - Error::NotDir => "Path is not dir", - Error::NotFile => "Path is not file", - Error::NotEmpty => "Directory is not empty", - Error::NoVersion => "File has no version", - - Error::ReadOnly => "Opened as read only", - Error::CannotRead => "Cannot read file", - Error::CannotWrite => "Cannot write file", - Error::NotWrite => "File does not write yet", - Error::NotFinish => "File does not finish yet", - Error::Closed => "File is closed", - - Error::Encode(ref err) => err.description(), - Error::Decode(ref err) => err.description(), - Error::Var(ref err) => err.description(), - Error::Io(ref err) => err.description(), - - #[cfg(feature = "storage-sqlite")] - Error::Sqlite(ref err) => err.description(), - - #[cfg(feature = "storage-redis")] - Error::Redis(ref err) => err.description(), - - #[cfg(feature = "storage-zbox")] - Error::Http(ref err) => err.description(), - #[cfg(feature = "storage-zbox")] - Error::HttpStatus(_) => "Http status error", - #[cfg(feature = "storage-zbox")] - Error::Json(ref err) => err.description(), - - #[cfg(feature = "storage-zbox-native")] - Error::Reqwest(ref err) => err.description(), - - #[cfg(feature = "storage-zbox-android")] - Error::Jni(ref err) => err.description(), - - #[cfg(target_arch = "wasm32")] - Error::RequestError => "Http request error", - } - } - - fn cause(&self) -> Option<&dyn StdError> { + fn source(&self) -> Option<&(dyn StdError + 'static)> { match *self { Error::Encode(ref err) => Some(err), Error::Decode(ref err) => Some(err), diff --git a/src/file.rs b/src/file.rs index 345d892..95bcf9c 100644 --- a/src/file.rs +++ b/src/file.rs @@ -1,4 +1,3 @@ -use std::error::Error as StdError; use std::fmt::{self, Debug}; use std::io::{self, Error as IoError, ErrorKind, Read, Seek, SeekFrom, Write}; @@ -583,7 +582,7 @@ impl Read for File { if !self.can_read { return Err(IoError::new( ErrorKind::Other, - Error::CannotRead.description(), + Error::CannotRead.to_string(), )); } @@ -649,7 +648,7 @@ impl Write for File { }, None => Err(IoError::new( ErrorKind::PermissionDenied, - Error::CannotWrite.description(), + Error::CannotWrite.to_string(), )), } } @@ -661,7 +660,7 @@ impl Seek for File { if self.wtr.is_some() { return Err(IoError::new( ErrorKind::Other, - Error::NotFinish.description(), + Error::NotFinish.to_string(), )); } diff --git a/src/lib.rs b/src/lib.rs index 036517a..1083e15 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -109,7 +109,7 @@ extern crate serde_derive; // convert zbox error to IO error macro_rules! map_io_err { ($x:expr) => { - $x.map_err(|e| IoError::new(ErrorKind::Other, e.description())); + $x.map_err(|e| IoError::new(ErrorKind::Other, e.to_string())); }; } diff --git a/src/repo.rs b/src/repo.rs index 962d473..da14830 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -634,7 +634,7 @@ fn open_file_with_options>( /// /// ```toml /// [dependencies] -/// zbox = { version = "0.9.1", features = ["storage-file"] } +/// zbox = { version = "0.9.2", features = ["storage-file"] } /// ``` /// /// # Create and open `Repo` diff --git a/src/trans/txmgr.rs b/src/trans/txmgr.rs index e04b0e3..f1c8af1 100644 --- a/src/trans/txmgr.rs +++ b/src/trans/txmgr.rs @@ -191,7 +191,7 @@ pub type TxMgrWeakRef = Weak>; // lock for running exclusive transactions lazy_static! { - static ref EXCL_TX_LOCK: Arc> = { Arc::new(Mutex::new(())) }; + static ref EXCL_TX_LOCK: Arc> = Arc::new(Mutex::new(())); } // Transaction handle diff --git a/src/version.rs b/src/version.rs index 255d086..e6e786a 100644 --- a/src/version.rs +++ b/src/version.rs @@ -6,4 +6,4 @@ pub const REPO_PATCH_VERSION: u8 = 0; /// Define ZboxFS library version pub const LIB_MAJOR_VERSION: u8 = 0; pub const LIB_MINOR_VERSION: u8 = 9; -pub const LIB_PATCH_VERSION: u8 = 1; +pub const LIB_PATCH_VERSION: u8 = 2; diff --git a/src/volume/storage/file/file_armor.rs b/src/volume/storage/file/file_armor.rs index 8a66dd3..43c4b90 100644 --- a/src/volume/storage/file/file_armor.rs +++ b/src/volume/storage/file/file_armor.rs @@ -1,5 +1,4 @@ use std::cmp::min; -use std::error::Error as StdError; use std::fmt::Debug; use std::io::{ Error as IoError, ErrorKind, Read, Result as IoResult, Take, Write, diff --git a/src/volume/storage/storage.rs b/src/volume/storage/storage.rs index 2923719..1dd292d 100644 --- a/src/volume/storage/storage.rs +++ b/src/volume/storage/storage.rs @@ -1,5 +1,4 @@ use std::cmp::min; -use std::error::Error as StdError; use std::fmt::{self, Debug, Display}; use std::io::{Error as IoError, ErrorKind, Read, Result as IoResult, Write}; use std::sync::{Arc, RwLock, Weak}; @@ -376,7 +375,7 @@ impl Read for WalReader { if err == Error::NotFound { IoError::new(ErrorKind::NotFound, "Wal not found") } else { - IoError::new(ErrorKind::Other, err.description()) + IoError::new(ErrorKind::Other, err.to_string()) } })?; @@ -497,7 +496,7 @@ impl Read for Reader { "Blocks not found", ) } else { - IoError::new(ErrorKind::Other, err.description()) + IoError::new(ErrorKind::Other, err.to_string()) } })?; read += read_len; diff --git a/tests/common/fuzzer.rs b/tests/common/fuzzer.rs index 5e9c715..4d9b9fb 100644 --- a/tests/common/fuzzer.rs +++ b/tests/common/fuzzer.rs @@ -347,7 +347,7 @@ impl Step { buf.put_u64_le(self.data_len as u64); let mut s = self.name.clone().into_bytes(); s.resize(32, 0); - buf.put(s); + buf.put_slice(&s); file.write_all(&buf).unwrap(); } diff --git a/tests/fuzz.rs b/tests/fuzz.rs index 8b4ad5c..85cc001 100644 --- a/tests/fuzz.rs +++ b/tests/fuzz.rs @@ -10,7 +10,6 @@ extern crate zbox; mod common; -use std::error::Error as StdError; use std::path::Path; use std::sync::{Arc, RwLock}; @@ -26,7 +25,7 @@ macro_rules! is_faulty_err { || cfg!(feature = "storage-zbox-faulty") { match $x { - Err(ref err) if err.description() == "Faulty error" => true, + Err(ref err) if err.to_string() == "Faulty error" => true, _ => false, } } else {