fix the commit handling again
This commit is contained in:
parent
37d14fb93e
commit
a499483520
@ -159,8 +159,13 @@ impl MathApp {
|
|||||||
let data = get_localstorage().get_item(DATA_NAME).ok()??;
|
let data = get_localstorage().get_item(DATA_NAME).ok()??;
|
||||||
let (commit, cached_data) = crate::misc::hashed_storage_read(&data)?;
|
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());
|
tracing::info!("Reading decompression cache. Bytes: {}", cached_data.len());
|
||||||
return Some(cached_data.to_vec());
|
return Some(cached_data.to_vec());
|
||||||
} else {
|
} else {
|
||||||
@ -176,10 +181,14 @@ impl MathApp {
|
|||||||
|
|
||||||
// TODO: stabilize FunctionManager serialize so it can persist across builds
|
// TODO: stabilize FunctionManager serialize so it can persist across builds
|
||||||
let (commit, func_data) = crate::misc::hashed_storage_read(&data)?;
|
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");
|
tracing::info!("Reading previous function data");
|
||||||
let function_manager: FunctionManager = bincode::deserialize(&func_data).ok()?;
|
let function_manager: FunctionManager = bincode::deserialize(&func_data).ok()?;
|
||||||
return Some(function_manager);
|
return Some(function_manager);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user