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

Upgrader remove raw unwrap and bump semver #8251

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ textwrap = "0.9"
num_cpus = "1.2"
number_prefix = "0.2"
rpassword = "1.0"
semver = "0.6"
semver = "0.9"
ansi_term = "0.10"
parking_lot = "0.5"
regex = "0.2"
Expand Down
17 changes: 12 additions & 5 deletions parity/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

//! Parity upgrade logic

use semver::Version;
use semver::{Version, SemVerError};
use std::collections::*;
use std::fs::{self, File, create_dir_all};
use std::env;
Expand All @@ -32,6 +32,13 @@ pub enum Error {
CannotCreateConfigPath,
CannotWriteVersionFile,
CannotUpdateVersionFile,
SemVer(SemVerError),
}

impl From<SemVerError> for Error {
fn from(err: SemVerError) -> Self {
Error::SemVer(err)
}
}

const CURRENT_VERSION: &'static str = env!("CARGO_PKG_VERSION");
Expand Down Expand Up @@ -74,15 +81,15 @@ fn push_upgrades(upgrades: &mut UpgradeList)
{
// dummy upgrade (remove when the first one is in)
upgrades.insert(
UpgradeKey { old_version: Version::parse("0.9.0").unwrap(), new_version: Version::parse("1.0.0").unwrap() },
UpgradeKey { old_version: Version::new(0, 9, 0), new_version: Version::new(1, 0, 0)},
dummy_upgrade);
}

fn upgrade_from_version(previous_version: &Version) -> Result<usize, Error> {
let mut upgrades = HashMap::new();
push_upgrades(&mut upgrades);

let current_version = Version::parse(CURRENT_VERSION).unwrap();
let current_version = Version::parse(CURRENT_VERSION)?;

let mut count = 0;
for upgrade_key in upgrades.keys() {
Expand Down Expand Up @@ -114,12 +121,12 @@ fn with_locked_version<F>(db_path: Option<&str>, script: F) -> Result<usize, Err
.ok()
.and_then(|_| Version::parse(&version_string).ok())
})
.unwrap_or_else(|| Version::parse("0.9.0").unwrap());
.unwrap_or(Version::new(0, 9, 0));

let mut lock = File::create(&path).map_err(|_| Error::CannotWriteVersionFile)?;
let result = script(&version);

let written_version = Version::parse(CURRENT_VERSION).unwrap();
let written_version = Version::parse(CURRENT_VERSION)?;
lock.write_all(written_version.to_string().as_bytes()).map_err(|_| Error::CannotUpdateVersionFile)?;
result
}
Expand Down
2 changes: 1 addition & 1 deletion rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ parking_lot = "0.5"
rand = "0.4"
rust-crypto = "0.2"
rustc-hex = "1.0"
semver = "0.6"
semver = "0.9"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ log = "0.3"
env_logger = "0.4"
rand = "0.4"
heapsize = "0.4"
semver = "0.6"
semver = "0.9"
smallvec = { version = "0.4", features = ["heapsizeof"] }
parking_lot = "0.5"
ipnetwork = "0.12.6"
Expand Down
2 changes: 1 addition & 1 deletion updater/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ethabi = "5.1"
ethabi-derive = "5.0"
ethabi-contract = "5.0"
target_info = "0.1"
semver = "0.6"
semver = "0.9"
ethcore = { path = "../ethcore" }
ethsync = { path = "../sync" }
ethcore-bytes = { path = "../util/bytes" }
Expand Down
2 changes: 1 addition & 1 deletion util/version/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ target_info = "0.1"

[build-dependencies]
vergen = "0.1"
rustc_version = "0.2.0"
rustc_version = "0.2"
toml = "0.4"

[features]
Expand Down