Skip to content

Commit

Permalink
Fix: support encrypted drives (shorten script file names) #1150
Browse files Browse the repository at this point in the history
  • Loading branch information
sagiegurari committed Aug 30, 2024
1 parent ee9ac45 commit 2e9a505
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## CHANGELOG

### v0.37.17

* Fix: support encrypted drives (shorten script file names) #1150

### v0.37.16 (2024-08-30)

* Enhancement: Expand condition_script_runner_args #1132 (thanks @wmmc88)
Expand Down
8 changes: 7 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ indexmap = { version = "^2", features = ["serde"] }
itertools = "^0.13"
lenient_semver = "^0.4.2"
log = "^0.4"
md5 = "^0.7"
once_cell = "^1.19.0"
petgraph = "^0.6.5"
regex = "^1.10"
Expand All @@ -73,7 +74,6 @@ serde = "^1"
serde_derive = "^1"
serde_ignored = "^0.1"
serde_json = "^1"
sha2 = "^0.10"
shell2batch = "^0.4.5"
strip-ansi-escapes = "^0.2"
strum_macros = "0.26.4"
Expand Down
16 changes: 3 additions & 13 deletions src/lib/scriptengine/script_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use crate::error::CargoMakeError;
use crate::io::create_text_file;
use fsio::file::write_text_file;
use fsio::path::as_path::AsPath;
use sha2::{Digest, Sha256};
use std::fmt::Write;
use md5;
use std::path::PathBuf;

pub(crate) fn create_script_file(
Expand All @@ -31,8 +30,8 @@ pub(crate) fn create_persisted_script_file(
let text = script_text.join("\n");

let string_bytes = text.as_bytes();
let bytes = Sha256::digest(string_bytes);
let file_name = bytes_to_hex(&bytes[..])?;
let bytes = md5::compute(string_bytes);
let file_name = format!("{:x}", bytes);

let default_target_directory = envmnt::get_or("CARGO_MAKE_CRATE_TARGET_DIRECTORY", "target");
let directory = envmnt::get_or(
Expand Down Expand Up @@ -61,12 +60,3 @@ pub(crate) fn create_persisted_script_file(
}
}
}

fn bytes_to_hex(bytes: &[u8]) -> Result<String, CargoMakeError> {
let mut hex_string = String::with_capacity(2 * bytes.len());
for byte in bytes {
write!(hex_string, "{:02X}", byte)?;
}

Ok(hex_string)
}

0 comments on commit 2e9a505

Please sign in to comment.