Include version in cache key

This commit is contained in:
Charles Marsh 2022-08-13 11:55:47 -04:00
parent 4aae3bfacb
commit 70f1677c8e
3 changed files with 7 additions and 6 deletions

2
Cargo.lock generated
View File

@ -1493,7 +1493,7 @@ dependencies = [
[[package]] [[package]]
name = "rust-python-linter" name = "rust-python-linter"
version = "0.0.6" version = "0.0.7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "rust-python-linter" name = "rust-python-linter"
version = "0.0.6" version = "0.0.7"
edition = "2021" edition = "2021"
[lib] [lib]
@ -13,7 +13,7 @@ bincode = { version = "1.3.3" }
cacache = { version = "10.0.1" } cacache = { version = "10.0.1" }
chrono = { version = "0.4.21" } chrono = { version = "0.4.21" }
clap = { version = "3.2.16", features = ["derive"] } clap = { version = "3.2.16", features = ["derive"] }
clearscreen = "1.0.10" clearscreen = { version = "1.0.10" }
colored = { version = "2.0.0" } colored = { version = "2.0.0" }
fern = { version = "0.6.1" } fern = { version = "0.6.1" }
log = { version = "0.4.17" } log = { version = "0.4.17" }

View File

@ -1,4 +1,3 @@
use std::borrow::Cow;
use std::os::unix::fs::MetadataExt; use std::os::unix::fs::MetadataExt;
use std::path::Path; use std::path::Path;
@ -8,6 +7,8 @@ use serde::{Deserialize, Serialize};
use crate::message::Message; use crate::message::Message;
const VERSION: &str = env!("CARGO_PKG_VERSION");
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
struct CacheMetadata { struct CacheMetadata {
size: u64, size: u64,
@ -66,8 +67,8 @@ fn cache_dir() -> &'static str {
"./.cache" "./.cache"
} }
fn cache_key(path: &Path) -> Cow<str> { fn cache_key(path: &Path) -> String {
path.to_string_lossy() format!("{}@{}", path.to_string_lossy(), VERSION)
} }
pub fn get(path: &Path, mode: &Mode) -> Option<Vec<Message>> { pub fn get(path: &Path, mode: &Mode) -> Option<Vec<Message>> {