Skip to content

Commit 1c42d28

Browse files
Merge pull request #532 from SierraSoftworks/dependabot/cargo/sha2-0.11.0
chore(deps): Bump sha2 from 0.10.9 to 0.11.0
2 parents 4c1ec1e + cd0c16f commit 1c42d28

3 files changed

Lines changed: 69 additions & 13 deletions

File tree

Cargo.lock

Lines changed: 62 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ rstest = "0.26.1"
2727
serde = { version = "1.0.228", features = ["derive", "alloc"] }
2828
serde_json = "1.0.149"
2929
serde_yaml = "0.9.34"
30-
sha2 = "0.10.9"
30+
sha2 = "0.11.0"
3131
tokio = { version = "1.50.0", features = [
3232
"macros",
3333
"rt",

src/engines/http_file.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,17 @@ impl BackupEngine<HttpFile> for HttpFileEngine {
195195
drop(file);
196196

197197
let shasum = shasum.finalize();
198+
let shasum_hex: String = shasum.iter().map(|b| format!("{b:02x}")).collect();
198199
if let Some(existing_sha256) = self.get_existing_sha256(&target_path).await
199-
&& existing_sha256 == format!("{:x}", shasum)
200+
&& existing_sha256 == shasum_hex
200201
{
201202
tokio::fs::remove_file(&temp_path).await.map_err(|e| human_errors::wrap_user(
202203
e,
203204
format!("Unable to remove temporary backup file '{}' after verifying that it is a duplicate of the existing file.", temp_path.display()),
204205
&["Make sure that you have write (and delete) permission on the backup directory and try again."],
205206
))?;
206207
return Ok(BackupState::Unchanged(Some(format!(
207-
"at sha256@{shasum:x}"
208+
"at sha256@{shasum_hex}"
208209
))));
209210
}
210211

@@ -217,14 +218,14 @@ impl BackupEngine<HttpFile> for HttpFileEngine {
217218
entity
218219
.last_modified
219220
.map(|m| format!("at {}", m.format("%Y-%m-%dT%H:%M:%S")))
220-
.or(Some(format!("at sha256:{shasum:x}"))),
221+
.or(Some(format!("at sha256:{shasum_hex}"))),
221222
)
222223
} else {
223224
BackupState::New(
224225
entity
225226
.last_modified
226227
.map(|m| format!("at {}", m.format("%Y-%m-%dT%H:%M:%S")))
227-
.or(Some(format!("at sha256:{shasum:x}"))),
228+
.or(Some(format!("at sha256:{shasum_hex}"))),
228229
)
229230
};
230231

@@ -242,7 +243,7 @@ impl BackupEngine<HttpFile> for HttpFileEngine {
242243
.unwrap_or_default()
243244
.to_string_lossy()
244245
)),
245-
format!("{:x}", shasum),
246+
shasum_hex,
246247
)
247248
.await
248249
.wrap_user_err(

0 commit comments

Comments
 (0)