mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 04:45:01 +00:00
Keep track of when files are last seen in the cache (#5214)
## Summary And remove cached files that we haven't seen for a certain period of time, currently 30 days. For the last seen timestamp we actually use an `u64`, it's smaller on disk than `SystemTime` (which size is OS dependent) and fits in an `AtomicU64` which we can use to update it without locks. ## Test Plan Added a new unit test, run by `cargo test`.
This commit is contained in:
parent
2dfa6ff58d
commit
1c638264b2
3 changed files with 146 additions and 58 deletions
|
@ -25,7 +25,7 @@ use ruff_python_ast::imports::ImportMap;
|
|||
use ruff_python_ast::source_code::{LineIndex, SourceCode, SourceFileBuilder};
|
||||
use ruff_python_stdlib::path::is_project_toml;
|
||||
|
||||
use crate::cache::{Cache, FileCache};
|
||||
use crate::cache::Cache;
|
||||
|
||||
#[derive(Debug, Default, PartialEq)]
|
||||
pub(crate) struct Diagnostics {
|
||||
|
@ -208,10 +208,14 @@ pub(crate) fn lint_path(
|
|||
let imports = imports.unwrap_or_default();
|
||||
|
||||
if let Some((cache, relative_path, file_last_modified)) = caching {
|
||||
// We don't cache parsing errors.
|
||||
if parse_error.is_none() {
|
||||
// We don't cache parsing error.
|
||||
let file_cache = FileCache::new(file_last_modified, &messages, &imports);
|
||||
cache.update(relative_path.to_owned(), file_cache);
|
||||
cache.update(
|
||||
relative_path.to_owned(),
|
||||
file_last_modified,
|
||||
&messages,
|
||||
&imports,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue