diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-05-29 14:38:18 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-29 18:38:18 +0000 |
commit | 94f040ac2867706d261e2fe1ec8bc2c4263eb6ab (patch) | |
tree | 5eaed4d41efd8d25da839bc29b8d32554e1a0fca /cli/cache/emit.rs | |
parent | fada25b0dd593efee496dabb48ed9cb7a9cb6647 (diff) |
fix: bump cache sqlite dbs to v2 for WAL journal mode change (#24030)
In https://github.com/denoland/deno/pull/23955 we changed the sqlite db
journal mode to WAL. This causes issues when someone is running an old
version of Deno using TRUNCATE and a new version because the two fight
against each other.
Diffstat (limited to 'cli/cache/emit.rs')
-rw-r--r-- | cli/cache/emit.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/cli/cache/emit.rs b/cli/cache/emit.rs index 29a9e9694..ac7c09a9a 100644 --- a/cli/cache/emit.rs +++ b/cli/cache/emit.rs @@ -14,8 +14,8 @@ use super::FastInsecureHasher; #[derive(Debug, Deserialize, Serialize)] struct EmitMetadata { - pub source_hash: String, - pub emit_hash: String, + pub source_hash: u64, + pub emit_hash: u64, } /// The cache that stores previously emitted files. @@ -52,7 +52,7 @@ impl EmitCache { // load and verify the meta data file is for this source and CLI version let bytes = self.disk_cache.get(&meta_filename).ok()?; let meta: EmitMetadata = serde_json::from_slice(&bytes).ok()?; - if meta.source_hash != expected_source_hash.to_string() { + if meta.source_hash != expected_source_hash { return None; } @@ -112,7 +112,7 @@ impl EmitCache { // save the metadata let metadata = EmitMetadata { - source_hash: source_hash.to_string(), + source_hash, emit_hash: compute_emit_hash(code.as_bytes(), self.cli_version), }; self @@ -138,16 +138,15 @@ impl EmitCache { } } -fn compute_emit_hash(bytes: &[u8], cli_version: &str) -> String { +fn compute_emit_hash(bytes: &[u8], cli_version: &str) -> u64 { // it's ok to use an insecure hash here because // if someone can change the emit source then they // can also change the version hash - FastInsecureHasher::new() + FastInsecureHasher::new_without_deno_version() // use cli_version param instead .write(bytes) // emit should not be re-used between cli versions - .write(cli_version.as_bytes()) + .write_str(cli_version) .finish() - .to_string() } #[cfg(test)] |