fix the commit handling again

This commit is contained in:
Simon Gardling 2025-12-03 00:54:27 -05:00
parent 37d14fb93e
commit a499483520
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D

View File

@ -159,8 +159,13 @@ impl MathApp {
let data = get_localstorage().get_item(DATA_NAME).ok()??;
let (commit, cached_data) = crate::misc::hashed_storage_read(&data)?;
// Build expected commit hash
let commit_bytes = build::SHORT_COMMIT.as_bytes();
let mut expected_commit: crate::misc::HashBytes = [0u8; crate::misc::HASH_LENGTH];
let len = commit_bytes.len().min(crate::misc::HASH_LENGTH);
expected_commit[..len].copy_from_slice(&commit_bytes[..len]);
if commit == unsafe { std::mem::transmute::<&str, crate::misc::HashBytes>(build::SHORT_COMMIT) } {
if commit == expected_commit {
tracing::info!("Reading decompression cache. Bytes: {}", cached_data.len());
return Some(cached_data.to_vec());
} else {
@ -176,10 +181,14 @@ impl MathApp {
// TODO: stabilize FunctionManager serialize so it can persist across builds
let (commit, func_data) = crate::misc::hashed_storage_read(&data)?;
let func_data: &[u8] = &func_data;
// Build expected commit hash
let commit_bytes = build::SHORT_COMMIT.as_bytes();
let mut expected_commit: crate::misc::HashBytes = [0u8; crate::misc::HASH_LENGTH];
let len = commit_bytes.len().min(crate::misc::HASH_LENGTH);
expected_commit[..len].copy_from_slice(&commit_bytes[..len]);
if commit == unsafe { std::mem::transmute::<&str, &[u8]>(build::SHORT_COMMIT) } {
if commit == expected_commit {
tracing::info!("Reading previous function data");
let function_manager: FunctionManager = bincode::deserialize(&func_data).ok()?;
return Some(function_manager);