From cffcf45dcdd6feddfd54e4554f0389e464582982 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Fri, 6 Sep 2024 09:54:19 +0200 Subject: [PATCH 1/3] Fix clippy warning from rust 1.81 --- mithril-aggregator/src/snapshotter.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mithril-aggregator/src/snapshotter.rs b/mithril-aggregator/src/snapshotter.rs index 1ff4b460915..a1cd79f67aa 100644 --- a/mithril-aggregator/src/snapshotter.rs +++ b/mithril-aggregator/src/snapshotter.rs @@ -94,7 +94,7 @@ pub enum SnapshotError { impl Snapshotter for CompressedArchiveSnapshotter { fn snapshot(&self, archive_name: &str) -> StdResult { let archive_path = self.ongoing_snapshot_directory.join(archive_name); - let filesize = self.create_and_verify_archive(&archive_path).map_err(|err| { + let filesize = self.create_and_verify_archive(&archive_path).inspect_err(|_err| { if archive_path.exists() { if let Err(remove_error) = std::fs::remove_file(&archive_path) { warn!( @@ -104,8 +104,6 @@ impl Snapshotter for CompressedArchiveSnapshotter { ); } } - - err }).with_context(|| format!("CompressedArchiveSnapshotter can not create and verify archive: '{}'", archive_path.display()))?; Ok(OngoingSnapshot { From 16a4f8b7f6d7b5aebed590aabd0e19e358a1a2d7 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Fri, 6 Sep 2024 09:57:53 +0200 Subject: [PATCH 2/3] style: remove unnecessary `fs` path prefix in snapshotter As `std::fs::Self` is imported in the file. --- mithril-aggregator/src/snapshotter.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/mithril-aggregator/src/snapshotter.rs b/mithril-aggregator/src/snapshotter.rs index a1cd79f67aa..9965794e6e4 100644 --- a/mithril-aggregator/src/snapshotter.rs +++ b/mithril-aggregator/src/snapshotter.rs @@ -96,7 +96,7 @@ impl Snapshotter for CompressedArchiveSnapshotter { let archive_path = self.ongoing_snapshot_directory.join(archive_name); let filesize = self.create_and_verify_archive(&archive_path).inspect_err(|_err| { if archive_path.exists() { - if let Err(remove_error) = std::fs::remove_file(&archive_path) { + if let Err(remove_error) = fs::remove_file(&archive_path) { warn!( " > Post snapshotter.snapshot failure, could not remove temporary archive at path: path:{}, err: {}", archive_path.display(), @@ -121,7 +121,7 @@ impl CompressedArchiveSnapshotter { compression_algorithm: SnapshotterCompressionAlgorithm, ) -> StdResult { if ongoing_snapshot_directory.exists() { - std::fs::remove_dir_all(&ongoing_snapshot_directory).with_context(|| { + fs::remove_dir_all(&ongoing_snapshot_directory).with_context(|| { format!( "Can not remove snapshotter directory: '{}'.", ongoing_snapshot_directory.display() @@ -129,7 +129,7 @@ impl CompressedArchiveSnapshotter { })?; } - std::fs::create_dir(&ongoing_snapshot_directory).map_err(|e| { + fs::create_dir(&ongoing_snapshot_directory).map_err(|e| { DependenciesBuilderError::Initialization { message: format!( "Can not create snapshotter directory: '{}'.", @@ -147,7 +147,7 @@ impl CompressedArchiveSnapshotter { } fn get_file_size(filepath: &Path) -> StdResult { - let res = std::fs::metadata(filepath) + let res = fs::metadata(filepath) .map_err(|e| SnapshotError::GeneralError(e.to_string()))? .len(); Ok(res) @@ -454,12 +454,7 @@ mod tests { .unwrap(), ); - assert_eq!( - 0, - std::fs::read_dir(pending_snapshot_directory) - .unwrap() - .count() - ); + assert_eq!(0, fs::read_dir(pending_snapshot_directory).unwrap().count()); } #[test] @@ -485,7 +480,7 @@ mod tests { let _ = snapshotter .snapshot("whatever.tar.gz") .expect_err("Snapshotter::snapshot should fail if the db is empty."); - let remaining_files: Vec = std::fs::read_dir(&pending_snapshot_directory) + let remaining_files: Vec = fs::read_dir(&pending_snapshot_directory) .unwrap() .map(|f| f.unwrap().file_name().to_str().unwrap().to_owned()) .collect(); From 9149960b5584e61a57d3ef77919c286b58a29d82 Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Fri, 6 Sep 2024 09:59:10 +0200 Subject: [PATCH 3/3] Upgrade `mithril-aggregator` version from `0.5.58` to `0.5.59` --- Cargo.lock | 2 +- mithril-aggregator/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e2dcd5ed1f2..b52e9d0e965 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3552,7 +3552,7 @@ dependencies = [ [[package]] name = "mithril-aggregator" -version = "0.5.58" +version = "0.5.59" dependencies = [ "anyhow", "async-trait", diff --git a/mithril-aggregator/Cargo.toml b/mithril-aggregator/Cargo.toml index 54275e14ee6..95284120e3a 100644 --- a/mithril-aggregator/Cargo.toml +++ b/mithril-aggregator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-aggregator" -version = "0.5.58" +version = "0.5.59" description = "A Mithril Aggregator server" authors = { workspace = true } edition = { workspace = true }