Skip to content

Commit 6f9da0c

Browse files
authored
Merge pull request #1918 from input-output-hk/djo/rust_1.81
Fix clippy warnings from Rust 1.81
2 parents 899f86c + 9149960 commit 6f9da0c

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-aggregator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-aggregator"
3-
version = "0.5.58"
3+
version = "0.5.59"
44
description = "A Mithril Aggregator server"
55
authors = { workspace = true }
66
edition = { workspace = true }

mithril-aggregator/src/snapshotter.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,16 @@ pub enum SnapshotError {
9494
impl Snapshotter for CompressedArchiveSnapshotter {
9595
fn snapshot(&self, archive_name: &str) -> StdResult<OngoingSnapshot> {
9696
let archive_path = self.ongoing_snapshot_directory.join(archive_name);
97-
let filesize = self.create_and_verify_archive(&archive_path).map_err(|err| {
97+
let filesize = self.create_and_verify_archive(&archive_path).inspect_err(|_err| {
9898
if archive_path.exists() {
99-
if let Err(remove_error) = std::fs::remove_file(&archive_path) {
99+
if let Err(remove_error) = fs::remove_file(&archive_path) {
100100
warn!(
101101
" > Post snapshotter.snapshot failure, could not remove temporary archive at path: path:{}, err: {}",
102102
archive_path.display(),
103103
remove_error
104104
);
105105
}
106106
}
107-
108-
err
109107
}).with_context(|| format!("CompressedArchiveSnapshotter can not create and verify archive: '{}'", archive_path.display()))?;
110108

111109
Ok(OngoingSnapshot {
@@ -123,15 +121,15 @@ impl CompressedArchiveSnapshotter {
123121
compression_algorithm: SnapshotterCompressionAlgorithm,
124122
) -> StdResult<CompressedArchiveSnapshotter> {
125123
if ongoing_snapshot_directory.exists() {
126-
std::fs::remove_dir_all(&ongoing_snapshot_directory).with_context(|| {
124+
fs::remove_dir_all(&ongoing_snapshot_directory).with_context(|| {
127125
format!(
128126
"Can not remove snapshotter directory: '{}'.",
129127
ongoing_snapshot_directory.display()
130128
)
131129
})?;
132130
}
133131

134-
std::fs::create_dir(&ongoing_snapshot_directory).map_err(|e| {
132+
fs::create_dir(&ongoing_snapshot_directory).map_err(|e| {
135133
DependenciesBuilderError::Initialization {
136134
message: format!(
137135
"Can not create snapshotter directory: '{}'.",
@@ -149,7 +147,7 @@ impl CompressedArchiveSnapshotter {
149147
}
150148

151149
fn get_file_size(filepath: &Path) -> StdResult<u64> {
152-
let res = std::fs::metadata(filepath)
150+
let res = fs::metadata(filepath)
153151
.map_err(|e| SnapshotError::GeneralError(e.to_string()))?
154152
.len();
155153
Ok(res)
@@ -456,12 +454,7 @@ mod tests {
456454
.unwrap(),
457455
);
458456

459-
assert_eq!(
460-
0,
461-
std::fs::read_dir(pending_snapshot_directory)
462-
.unwrap()
463-
.count()
464-
);
457+
assert_eq!(0, fs::read_dir(pending_snapshot_directory).unwrap().count());
465458
}
466459

467460
#[test]
@@ -487,7 +480,7 @@ mod tests {
487480
let _ = snapshotter
488481
.snapshot("whatever.tar.gz")
489482
.expect_err("Snapshotter::snapshot should fail if the db is empty.");
490-
let remaining_files: Vec<String> = std::fs::read_dir(&pending_snapshot_directory)
483+
let remaining_files: Vec<String> = fs::read_dir(&pending_snapshot_directory)
491484
.unwrap()
492485
.map(|f| f.unwrap().file_name().to_str().unwrap().to_owned())
493486
.collect();

0 commit comments

Comments
 (0)