Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
FrostyCoolSlug committed Nov 24, 2024
1 parent 1f3caeb commit d5fa541
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 23 deletions.
6 changes: 2 additions & 4 deletions client/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use goxlr_types::{
SampleBank, SampleButtons, SamplePlayOrder, SamplePlaybackMode, SimpleColourTargets,
WaterfallDirection,
};
use std::str::FromStr;
use std::path::PathBuf;
use std::str::FromStr;

#[derive(Parser, Debug)]
#[command(about, version, author)]
Expand Down Expand Up @@ -186,9 +186,7 @@ fn percent_value_float(s: &str) -> Result<f32, String> {
#[command(arg_required_else_help = true)]
#[allow(clippy::enum_variant_names)]
pub enum FirmwareCommands {
FirmwareUpdate {
path: Option<PathBuf>,
},
FirmwareUpdate { path: Option<PathBuf> },

ContinueFirmwareUpdate,
ClearFirmwareUpdate,
Expand Down
39 changes: 27 additions & 12 deletions client/src/runner.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
use crate::cli::{
AnimationCommands, ButtonGroupLightingCommands, ButtonLightingCommands, CompressorCommands, CoughButtonBehaviours, Echo, EffectsCommands, EqualiserCommands, EqualiserMiniCommands, FaderCommands, FaderLightingCommands, FadersAllLightingCommands, FirmwareCommands, Gender, HardTune, LightingCommands, Megaphone, MicrophoneCommands, NoiseGateCommands, Pitch, ProfileAction, ProfileType, Reverb, Robot, SamplerCommands, Scribbles, SubCommands, SubmixCommands
AnimationCommands, ButtonGroupLightingCommands, ButtonLightingCommands, CompressorCommands,
CoughButtonBehaviours, Echo, EffectsCommands, EqualiserCommands, EqualiserMiniCommands,
FaderCommands, FaderLightingCommands, FadersAllLightingCommands, FirmwareCommands, Gender,
HardTune, LightingCommands, Megaphone, MicrophoneCommands, NoiseGateCommands, Pitch,
ProfileAction, ProfileType, Reverb, Robot, SamplerCommands, Scribbles, SubCommands,
SubmixCommands,
};
use crate::cli::{Cli, DeviceSettings};
use crate::microphone::apply_microphone_controls;
Expand Down Expand Up @@ -1018,17 +1023,27 @@ pub async fn run_cli() -> Result<()> {
.await?;
}
},
SubCommands::Firmware { command } => {
match command {
FirmwareCommands::FirmwareUpdate { path } => {
client.daemon_command(DaemonRequest::RunFirmwareUpdate(serial.to_string(), path.clone(), false)).await?;
},
FirmwareCommands::ContinueFirmwareUpdate => {
client.daemon_command(DaemonRequest::ContinueFirmwareUpdate(serial.to_string())).await?;
},
FirmwareCommands::ClearFirmwareUpdate => {
client.daemon_command(DaemonRequest::ClearFirmwareState(serial.to_string())).await?;
}
SubCommands::Firmware { command } => match command {
FirmwareCommands::FirmwareUpdate { path } => {
client
.daemon_command(DaemonRequest::RunFirmwareUpdate(
serial.to_string(),
path.clone(),
false,
))
.await?;
}
FirmwareCommands::ContinueFirmwareUpdate => {
client
.daemon_command(DaemonRequest::ContinueFirmwareUpdate(
serial.to_string(),
))
.await?;
}
FirmwareCommands::ClearFirmwareUpdate => {
client
.daemon_command(DaemonRequest::ClearFirmwareState(serial.to_string()))
.await?;
}
},
}
Expand Down
21 changes: 17 additions & 4 deletions daemon/src/firmware/firmware_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ pub async fn start_firmware_update(settings: FirmwareUpdateSettings) {
// the file_info, and the UI can then send a 'Continue' if the user is happy with the info, otherwise
// we just go with the update.
if !settings.force && (file_info.version <= device.current_firmware) {
warn!("Pausing, File: {}, Current: {}", file_info.version, device.current_firmware);
warn!(
"Pausing, File: {}, Current: {}",
file_info.version, device.current_firmware
);
let _ = set_update_state(&device.serial, sender, UpdateState::Pause(file_info)).await;
} else {
info!("Downloaded firmware is newer than current, proceeding without prompt..");
Expand Down Expand Up @@ -206,7 +209,10 @@ async fn download_firmware(device: &FirmwareUpdateDevice, sender: Sender) -> Res
let url = format!("{}{}", FIRMWARE_BASE, file_name.0);
let output_path = std::env::temp_dir().join(file_name.0);

info!("Downloading Firmware, URL: {}, Expected Version: {}", url, file_name.1);
info!(
"Downloading Firmware, URL: {}, Expected Version: {}",
url, file_name.1
);

if output_path.exists() && fs::remove_file(&output_path).is_err() {
bail!("Error Cleaning old firmware");
Expand Down Expand Up @@ -241,9 +247,16 @@ async fn download_firmware(device: &FirmwareUpdateDevice, sender: Sender) -> Res
}

if let Ok(data) = firmware_info.path.metadata() {
info!("Download complete, file: {}, size: {}", firmware_info.path.to_string_lossy(), data.len());
info!(
"Download complete, file: {}, size: {}",
firmware_info.path.to_string_lossy(),
data.len()
);
} else {
info!("Download complete, file: {}, size: unknown", firmware_info.path.to_string_lossy());
info!(
"Download complete, file: {}, size: unknown",
firmware_info.path.to_string_lossy()
);
}
return Ok(firmware_info);
}
Expand Down
6 changes: 3 additions & 3 deletions daemon/src/primary_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,12 +506,12 @@ pub async fn spawn_usb_handler(
file,
force,
};
let update_state = FirmwareUpdateState {
let update_state = FirmwareUpdateState {
settings: update_settings.clone(),
status: FirmwareStatus {
status: FirmwareStatus {
state: UpdateState::Starting,
progress: 0,
error: None
error: None
},
};

Expand Down

0 comments on commit d5fa541

Please sign in to comment.