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

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>> {