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]]
name = "rust-python-linter"
version = "0.0.6"
version = "0.0.7"
dependencies = [
"anyhow",
"bincode",

View File

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

View File

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