Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
add zbox_version() function
Browse files Browse the repository at this point in the history
  • Loading branch information
burmecia committed Jun 4, 2019
1 parent f7c0426 commit 4a8b23c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
20 changes: 14 additions & 6 deletions src/base/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ use wasm_logger;
#[cfg(all(not(target_os = "android"), not(target_arch = "wasm32")))]
use env_logger;

/// Get ZboxFS version string.
///
/// This method return ZboxFS version as a string, e.g. "ZboxFS 0.8.0".
#[inline]
pub fn zbox_version() -> String {
format!("ZboxFS {}", Version::lib_version())
}

static INIT: Once = ONCE_INIT;

cfg_if! {
Expand All @@ -48,8 +56,8 @@ cfg_if! {
);
crypto::Crypto::init().expect("Initialise crypto failed");
debug!(
"ZboxFS v{} - Zero-details, privacy-focused in-app file system",
Version::current_lib_version()
"{} - Zero-details, privacy-focused in-app file system",
zbox_version()
);
});
}
Expand All @@ -59,8 +67,8 @@ cfg_if! {
wasm_logger::init(wasm_logger::Config::new(Level::Trace));
crypto::Crypto::init().expect("Initialise crypto failed");
debug!(
"ZboxFS v{} - Zero-details, privacy-focused in-app file system",
Version::current_lib_version()
"{} - Zero-details, privacy-focused in-app file system",
zbox_version()
);
});
}
Expand All @@ -80,8 +88,8 @@ cfg_if! {
env_logger::try_init().ok();
crypto::Crypto::init().expect("Initialise crypto failed");
debug!(
"ZboxFS v{} - Zero-details, privacy-focused in-app file system",
Version::current_lib_version()
"{} - Zero-details, privacy-focused in-app file system",
zbox_version()
);
});
}
Expand Down
7 changes: 3 additions & 4 deletions src/base/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@ pub struct Version {

impl Version {
#[inline]
pub fn current_repo_version() -> Self {
pub fn repo_version() -> Self {
Version {
major: version::REPO_MAJOR_VERSION,
minor: version::REPO_MINOR_VERSION,
patch: version::REPO_PATCH_VERSION,
}
}

#[allow(dead_code)]
#[inline]
pub fn current_lib_version() -> Self {
pub fn lib_version() -> Self {
Version {
major: version::LIB_MAJOR_VERSION,
minor: version::LIB_MINOR_VERSION,
Expand All @@ -31,7 +30,7 @@ impl Version {
}

pub fn match_repo_version(&self) -> bool {
let curr = Version::current_repo_version();
let curr = Version::repo_version();
self.major == curr.major && self.minor == curr.minor
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ mod version;
mod volume;

pub use self::base::crypto::{Cipher, MemLimit, OpsLimit};
pub use self::base::init_env;
pub use self::base::{init_env, zbox_version};
pub use self::error::{Error, Result};
pub use self::file::{File, VersionReader};
pub use self::fs::fnode::{DirEntry, FileType, Metadata, Version};
Expand Down
2 changes: 1 addition & 1 deletion src/volume/storage/zbox/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct Headers {
impl Headers {
fn new() -> Self {
let mut map = HeaderMap::new();
let ver = Version::current_lib_version().to_string();
let ver = Version::lib_version().to_string();

// add zbox version header
let version_header = HeaderName::from_static("zbox-version");
Expand Down
2 changes: 1 addition & 1 deletion src/volume/volume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl Volume {

// initialise info
self.info.id = Eid::new();
self.info.ver = Version::current_repo_version();
self.info.ver = Version::repo_version();
self.info.compress = cfg.compress;
self.info.cost = cfg.cost;
self.info.cipher = cfg.cipher;
Expand Down

0 comments on commit 4a8b23c

Please sign in to comment.