mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-18 11:20:40 +00:00
Log most recently modified file for cache-keys (#16338)
For https://github.com/astral-sh/uv/issues/16336. We previously weren't telling the user which file is responsible for rebuilding. --------- Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
This commit is contained in:
parent
857827da14
commit
944ff6c685
3 changed files with 27 additions and 7 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -5504,6 +5504,7 @@ dependencies = [
|
|||
"thiserror 2.0.17",
|
||||
"toml",
|
||||
"tracing",
|
||||
"uv-fs",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ doctest = false
|
|||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
uv-fs = { workspace = true }
|
||||
|
||||
fs-err = { workspace = true }
|
||||
globwalk = { workspace = true }
|
||||
schemars = { workspace = true, optional = true }
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
use std::borrow::Cow;
|
||||
use std::cmp::max;
|
||||
use std::collections::BTreeMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use serde::Deserialize;
|
||||
use tracing::{debug, warn};
|
||||
|
||||
use uv_fs::Simplified;
|
||||
|
||||
use crate::git_info::{Commit, Tags};
|
||||
use crate::glob::cluster_globs;
|
||||
use crate::timestamp::Timestamp;
|
||||
|
|
@ -63,7 +64,7 @@ impl CacheInfo {
|
|||
pub fn from_directory(directory: &Path) -> Result<Self, CacheInfoError> {
|
||||
let mut commit = None;
|
||||
let mut tags = None;
|
||||
let mut timestamp = None;
|
||||
let mut last_changed: Option<(PathBuf, Timestamp)> = None;
|
||||
let mut directories = BTreeMap::new();
|
||||
let mut env = BTreeMap::new();
|
||||
|
||||
|
|
@ -128,7 +129,12 @@ impl CacheInfo {
|
|||
);
|
||||
continue;
|
||||
}
|
||||
timestamp = max(timestamp, Some(Timestamp::from_metadata(&metadata)));
|
||||
let timestamp = Timestamp::from_metadata(&metadata);
|
||||
if last_changed.as_ref().is_none_or(|(_, prev_timestamp)| {
|
||||
*prev_timestamp < Timestamp::from_metadata(&metadata)
|
||||
}) {
|
||||
last_changed = Some((path, timestamp));
|
||||
}
|
||||
}
|
||||
CacheKey::Directory { dir } => {
|
||||
// Treat the path as a directory.
|
||||
|
|
@ -258,14 +264,25 @@ impl CacheInfo {
|
|||
}
|
||||
continue;
|
||||
}
|
||||
timestamp = max(timestamp, Some(Timestamp::from_metadata(&metadata)));
|
||||
let timestamp = Timestamp::from_metadata(&metadata);
|
||||
if last_changed.as_ref().is_none_or(|(_, prev_timestamp)| {
|
||||
*prev_timestamp < Timestamp::from_metadata(&metadata)
|
||||
}) {
|
||||
last_changed = Some((entry.into_path(), timestamp));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let timestamp = if let Some((path, timestamp)) = last_changed {
|
||||
debug!(
|
||||
"Computed cache info: {timestamp:?}, {commit:?}, {tags:?}, {env:?}, {directories:?}"
|
||||
"Computed cache info: {timestamp:?}, {commit:?}, {tags:?}, {env:?}, {directories:?}. Most recently modified: {}",
|
||||
path.user_display()
|
||||
);
|
||||
Some(timestamp)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
Ok(Self {
|
||||
timestamp,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue