diff options
author | Shaun Taheri <shaun@advancedtelematic.com> | 2016-06-18 15:36:22 +0200 |
---|---|---|
committer | Shaun Taheri <shaun@advancedtelematic.com> | 2016-06-21 15:33:41 +0200 |
commit | 13a552483b79150d7980823b749fc1d14d3eb1a8 (patch) | |
tree | 1683053366780df2f76b2f05a3af452aab843e36 /src/package_manager | |
parent | 9f56304fc2b3fdbacf5fcea971ee93d61a0d7e32 (diff) | |
download | rvi_sota_client-13a552483b79150d7980823b749fc1d14d3eb1a8.tar.gz |
Propagate shutdown signal to all threads
Diffstat (limited to 'src/package_manager')
-rw-r--r-- | src/package_manager/package_manager.rs | 20 | ||||
-rw-r--r-- | src/package_manager/tpm.rs | 2 |
2 files changed, 8 insertions, 14 deletions
diff --git a/src/package_manager/package_manager.rs b/src/package_manager/package_manager.rs index a31d303..1833eab 100644 --- a/src/package_manager/package_manager.rs +++ b/src/package_manager/package_manager.rs @@ -27,10 +27,6 @@ impl PackageManager { } } - pub fn from_file(filename: String, succeeds: bool) -> Self { - PackageManager::File { filename: filename, succeeds: succeeds } - } - pub fn installed_packages(&self) -> Result<Vec<Package>, Error> { match *self { PackageManager::Dpkg => dpkg::installed_packages(), @@ -58,15 +54,13 @@ impl PackageManager { impl Decodable for PackageManager { fn decode<D: Decoder>(d: &mut D) -> Result<PackageManager, D::Error> { - d.read_str().and_then(|s| parse_package_manager(s).map_err(|e| d.error(&e))) - } -} - -fn parse_package_manager(s: String) -> Result<PackageManager, String> { - match s.to_lowercase().as_str() { - "dpkg" => Ok(PackageManager::Dpkg), - "rpm" => Ok(PackageManager::Rpm), - _ => Ok(PackageManager::File { filename: s.to_string(), succeeds: true }), + d.read_str().and_then(|s| { + match s.to_lowercase().as_str() { + "dpkg" => Ok(PackageManager::Dpkg), + "rpm" => Ok(PackageManager::Rpm), + _ => Ok(PackageManager::File { filename: s.to_string(), succeeds: true }), + } + }) } } diff --git a/src/package_manager/tpm.rs b/src/package_manager/tpm.rs index aa17800..4c7da4c 100644 --- a/src/package_manager/tpm.rs +++ b/src/package_manager/tpm.rs @@ -1,10 +1,10 @@ +use chan::Receiver; use std::fmt::Debug; use std::fs::File; use std::fs::OpenOptions; use std::io::BufReader; use std::io::BufWriter; use std::io::prelude::*; -use std::sync::mpsc::Receiver; use datatype::{Error, Package, UpdateResultCode}; use package_manager::package_manager::InstallOutcome; |