Clean up codebase, fixing minor errors

This commit is contained in:
James 2019-06-23 20:27:35 +10:00
parent 9d1f4c2576
commit a447ef25b6
21 changed files with 47 additions and 16 deletions

View file

@ -1,3 +1,5 @@
//! frontend/mod.rs
//!
//! Provides the frontend interface, including HTTP server.
use std::sync::{Arc, RwLock};

View file

@ -1,3 +1,5 @@
//! frontend/rest/mod.rs
//!
//! Contains the main web server used within the application.
pub mod server;

View file

@ -1,3 +1,5 @@
//! frontend/rest/server.rs
//!
//! Contains the over-arching server object + methods to manipulate it.
use frontend::rest::services::WebService;

View file

@ -1,3 +1,5 @@
//! frontend/rest/services/attributes.rs
//!
//! The /api/attr call returns an executable script containing session variables.
use frontend::rest::services::default_future;

View file

@ -1,3 +1,5 @@
//! frontend/rest/services/config.rs
//!
//! The /api/config call returns the current installer framework configuration.
//!
//! This endpoint should be usable directly from a <script> tag during loading.

View file

@ -1,3 +1,5 @@
//! frontend/rest/services/default_path.rs
//!
//! The /api/default-path returns the default path for the application to install into.
use frontend::rest::services::default_future;

View file

@ -1,3 +1,5 @@
//! frontend/rest/services/exit.rs
//!
//! The /api/exit closes down the application.
use frontend::rest::services::default_future;

View file

@ -1,3 +1,5 @@
//! frontend/rest/services/install.rs
//!
//! The /api/install call installs a set of packages dictated by a POST request.
use frontend::rest::services::stream_progress;

View file

@ -1,3 +1,5 @@
//! frontend/rest/services/installation_status.rs
//!
//! The /api/installation-status call returns metadata relating to the current status of
//! the installation.
//!

View file

@ -1,3 +1,5 @@
//! frontend/rest/services/mod.rs
//!
//! Provides all services used by the REST server.
use std::sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard};

View file

@ -1,3 +1,5 @@
//! frontend/rest/services/packages.rs
//!
//! The /api/packages call returns all the currently installed packages.
use frontend::rest::services::default_future;

View file

@ -1,3 +1,5 @@
//! frontend/rest/services/static_files.rs
//!
//! The static files call returns static files embedded within the executable.
//!
//! e.g. index.html, main.js, ...

View file

@ -1,3 +1,5 @@
//! frontend/rest/services/uninstall.rs
//!
//! The /api/uninstall call uninstalls all packages.
use frontend::rest::services::default_future;

View file

@ -1,3 +1,5 @@
//! frontend/rest/services/update_updater.rs
//!
//! The /api/update-updater call attempts to update the currently running updater.
use frontend::rest::services::default_future;

View file

@ -1,3 +1,5 @@
//! frontend/ui/mod.rs
//!
//! Provides a web-view UI.
use web_view::Content;

View file

@ -14,7 +14,7 @@ pub fn assert_ssl(url: &str) -> Result<(), String> {
if url.starts_with("https://") {
Ok(())
} else {
Err(format!("Specified URL was not https"))
Err("Specified URL was not https".to_string())
}
}

View file

@ -109,14 +109,14 @@ pub struct LocalInstallation {
macro_rules! declare_messenger_callback {
($target:expr) => {
&|msg: &TaskMessage| match msg {
&TaskMessage::DisplayMessage(msg, progress) => {
&|msg: &TaskMessage| match *msg {
TaskMessage::DisplayMessage(msg, progress) => {
if let Err(v) = $target.send(InstallMessage::Status(msg.to_string(), progress as _))
{
error!("Failed to submit queue message: {:?}", v);
}
}
&TaskMessage::PackageInstalled => {
TaskMessage::PackageInstalled => {
if let Err(v) = $target.send(InstallMessage::PackageInstalled) {
error!("Failed to submit queue message: {:?}", v);
}

View file

@ -148,7 +148,7 @@ fn main() {
info!("Copy attempt failed: {:?}, retrying in 3 seconds.", e);
thread::sleep(time::Duration::from_millis(3000));
} else {
let _: () = Err(e).log_expect("Copying new binary failed");
Err::<(), _>(e).log_expect("Copying new binary failed");
}
}
}

View file

@ -49,10 +49,11 @@ impl ReleaseSource for GithubReleases {
match response.status() {
StatusCode::OK => {}
StatusCode::FORBIDDEN => {
return Err(format!(
return Err(
"GitHub is rate limiting you. Try moving to a internet connection \
that isn't shared, and/or disabling VPNs."
));
.to_string(),
);
}
_ => {
return Err(format!("Bad status code: {:?}.", response.status()));

View file

@ -32,13 +32,13 @@ impl Task for EnsureOnlyInstanceTask {
let exe = name;
if exe.ends_with("maintenancetool.exe") || exe.ends_with("maintenancetool") {
return Err(format!("Maintenance tool is already running!"));
return Err("Maintenance tool is already running!".to_string());
}
for package in &context.database.packages {
for file in &package.files {
if exe.ends_with(file) {
return Err(format!("The installed application is currently running!"));
return Err("The installed application is currently running!".to_string());
}
}
}
@ -52,6 +52,6 @@ impl Task for EnsureOnlyInstanceTask {
}
fn name(&self) -> String {
format!("EnsureOnlyInstanceTask")
"EnsureOnlyInstanceTask".to_string()
}
}

View file

@ -133,8 +133,8 @@ impl DependencyTree {
continue;
}
let result = i.execute(context, &|msg: &TaskMessage| match msg {
&TaskMessage::DisplayMessage(msg, progress) => {
let result = i.execute(context, &|msg: &TaskMessage| match *msg {
TaskMessage::DisplayMessage(msg, progress) => {
messenger(&TaskMessage::DisplayMessage(
msg,
progress / total_tasks + (1.0 / total_tasks) * f64::from(count),
@ -159,8 +159,8 @@ impl DependencyTree {
let task_result = self
.task
.execute(inputs, context, &|msg: &TaskMessage| match msg {
&TaskMessage::DisplayMessage(msg, progress) => {
.execute(inputs, context, &|msg: &TaskMessage| match *msg {
TaskMessage::DisplayMessage(msg, progress) => {
messenger(&TaskMessage::DisplayMessage(
msg,
progress / total_tasks + (1.0 / total_tasks) * f64::from(count),
@ -179,8 +179,8 @@ impl DependencyTree {
continue;
}
let result = i.execute(context, &|msg: &TaskMessage| match msg {
&TaskMessage::DisplayMessage(msg, progress) => {
let result = i.execute(context, &|msg: &TaskMessage| match *msg {
TaskMessage::DisplayMessage(msg, progress) => {
messenger(&TaskMessage::DisplayMessage(
msg,
progress / total_tasks + (1.0 / total_tasks) * f64::from(count),