Skip to content

Commit 094b3eb

Browse files
authored
fix(cli): file name instead of path on updater sig comment, closes #4467 (#4484)
1 parent 68a09b3 commit 094b3eb

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

.changes/updater-sig-metadata.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"cli.rs": patch
3+
"cli.js": patch
4+
---
5+
6+
Change the updater signature metadata to include the file name instead of its full path.

tooling/cli/src/helpers/updater_signature.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ pub fn sign_file<P>(
109109
where
110110
P: AsRef<Path>,
111111
{
112+
let bin_path = bin_path.as_ref();
112113
let decoded_secret = decode_key(private_key)?;
113114
let sk_box = SecretKeyBox::from_string(&decoded_secret)
114115
.with_context(|| "failed to load updater private key")?;
@@ -117,15 +118,16 @@ where
117118
.with_context(|| "incorrect updater private key password")?;
118119

119120
// We need to append .sig at the end it's where the signature will be stored
120-
let signature_path_string = format!("{}.sig", bin_path.as_ref().display());
121-
let signature_path = Path::new(&signature_path_string);
121+
let mut extension = bin_path.extension().unwrap().to_os_string();
122+
extension.push(".sig");
123+
let signature_path = bin_path.with_extension(extension);
122124

123-
let mut signature_box_writer = create_file(signature_path)?;
125+
let mut signature_box_writer = create_file(&signature_path)?;
124126

125127
let trusted_comment = format!(
126128
"timestamp:{}\tfile:{}",
127129
unix_timestamp(),
128-
bin_path.as_ref().display()
130+
bin_path.file_name().unwrap().to_string_lossy()
129131
);
130132

131133
let data_reader = open_data_file(bin_path)?;

0 commit comments

Comments
 (0)