Fixed clippy, updated dependencies
Some checks failed
Build Project / test (push) Failing after 9m3s
Some checks failed
Build Project / test (push) Failing after 9m3s
This commit is contained in:
20
src/util.rs
20
src/util.rs
@@ -1,4 +1,4 @@
|
||||
use std::{cmp::Reverse, fs, path::PathBuf};
|
||||
use std::{fs, path::PathBuf};
|
||||
|
||||
use log::{error, info};
|
||||
use semver::Version;
|
||||
@@ -47,7 +47,7 @@ pub fn get_files(
|
||||
root_path: &PathBuf,
|
||||
hostname: &str,
|
||||
) -> Result<Vec<OTAConfiguration>, GetFilesError> {
|
||||
info!("Getting all files from path {root_path:?}");
|
||||
info!("Getting all files from path {}", root_path.display());
|
||||
let mut configs = Vec::new();
|
||||
let product_name = root_path
|
||||
.file_name()
|
||||
@@ -59,7 +59,7 @@ pub fn get_files(
|
||||
info!("Reading entry: {entry:?}");
|
||||
let path = entry.path();
|
||||
if path.is_file() {
|
||||
info!("processing file: {:?}", path);
|
||||
info!("processing file: {}", path.display());
|
||||
// Splits the filename at the underscores. This is safe to do as names get sanitized on upload and are only uploaded by the pipeline
|
||||
let split_name: Vec<_> = path
|
||||
.file_name()
|
||||
@@ -81,22 +81,22 @@ pub fn get_files(
|
||||
let fw_url =
|
||||
format!("{hostname}/{service}/{board_type}/{board_config}/{version_replaced}.bin");
|
||||
let cfg = OTAConfiguration {
|
||||
version: version,
|
||||
version,
|
||||
url: fw_url,
|
||||
board: Some(board_type),
|
||||
config: Some(board_config),
|
||||
};
|
||||
configs.push(cfg);
|
||||
} else if path.is_dir() {
|
||||
println!("Directory: {path:?}");
|
||||
println!("Directory: {}", path.display());
|
||||
}
|
||||
}
|
||||
|
||||
Ok(configs)
|
||||
}
|
||||
|
||||
pub fn prune_files(path: PathBuf, service: Services, keep_last: usize) {
|
||||
let Ok(mut config_list) = get_files(&path, "irrelevant") else {
|
||||
pub fn prune_files(path: &PathBuf, service: &Services, keep_last: usize) {
|
||||
let Ok(mut config_list) = get_files(path, "irrelevant") else {
|
||||
error!("failed to get file list for pruning");
|
||||
return
|
||||
};
|
||||
@@ -110,7 +110,7 @@ pub fn prune_files(path: PathBuf, service: Services, keep_last: usize) {
|
||||
if let Err(e) = fs::remove_file(&path_to_remove) {
|
||||
error!("Failed to delete {path_to_remove}, {e:?}");
|
||||
return;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,13 +122,13 @@ mod tests {
|
||||
fn test_file_loading() {
|
||||
let expected_1 = OTAConfiguration {
|
||||
version: Version::parse("1.2.3").unwrap(),
|
||||
url: "example.com/firmware/waterlevel/INA233/1_2_3.bin".to_string(),
|
||||
url: "example.com/firmware/waterlevel/INA233/1-2-3.bin".to_string(),
|
||||
board: Some(BoardType::Waterlevel),
|
||||
config: Some(BoardConfig::INA233),
|
||||
};
|
||||
let expected_2 = OTAConfiguration {
|
||||
version: Version::parse("4.5.6").unwrap(),
|
||||
url: "example.com/firmware/waterlevel/INA226/4_5_6.bin".to_string(),
|
||||
url: "example.com/firmware/waterlevel/INA226/4-5-6.bin".to_string(),
|
||||
board: Some(BoardType::Waterlevel),
|
||||
config: Some(BoardConfig::INA226),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user