Skip to content

Commit 5094e1d

Browse files
committed
fix(cache): improve unrecognized database version error message
Explain that the cache may have been created by a newer version of Vite Task and suggest running `<program> cache clean`. https://claude.ai/code/session_01R6o7gtdDeEVkd6TXNgNi5q
1 parent 70ed66e commit 5094e1d

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

crates/vite_task/src/session/cache/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ pub fn split_path(path: &str) -> (Option<&str>, &str) {
176176

177177
impl ExecutionCache {
178178
#[tracing::instrument(level = "debug", skip_all)]
179-
pub fn load_from_path(path: &AbsolutePath) -> anyhow::Result<Self> {
179+
pub fn load_from_path(path: &AbsolutePath, program_name: &str) -> anyhow::Result<Self> {
180180
tracing::info!("Creating task cache directory at {:?}", path);
181181
std::fs::create_dir_all(path)?;
182182

@@ -211,7 +211,11 @@ impl ExecutionCache {
211211
}
212212
11 => break, // current version
213213
12.. => {
214-
return Err(anyhow::anyhow!("Unrecognized database version: {user_version}"));
214+
return Err(anyhow::anyhow!(
215+
"Unrecognized database version: {user_version}. \
216+
The cache may have been created by a newer version of Vite Task. \
217+
Run `{program_name} cache clean` to remove it."
218+
));
215219
}
216220
}
217221
}

crates/vite_task/src/session/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,8 @@ impl<'a> Session<'a> {
554554
///
555555
/// Returns an error if the cache database cannot be loaded or created.
556556
pub fn cache(&self) -> anyhow::Result<&ExecutionCache> {
557-
self.cache.get_or_try_init(|| ExecutionCache::load_from_path(&self.cache_path))
557+
self.cache
558+
.get_or_try_init(|| ExecutionCache::load_from_path(&self.cache_path, &self.program_name))
558559
}
559560

560561
pub fn workspace_path(&self) -> Arc<AbsolutePath> {

0 commit comments

Comments
 (0)