Reuse logical namespace keys during native file checks
This commit is contained in:
1 parent
4586d961e9
commit
af8f38bb78
2 files changed
+29
-10
No files matched your search
@@ -636,6 +636,8 @@ pub struct FileWorld {
|
||||
staged_generated: BTreeMap<PathBuf, PathBuf>,
|
||||
/// Actual host resource promotions, never inferred from serialized cache.
|
||||
protected_paths: BTreeSet<PathBuf>,
|
||||
// Logical path keys shared by namespace operations within a job.
|
||||
project_path_keys: OnceLock<BTreeSet<PathBuf>>,
|
||||
replay_gaps: Vec<String>,
|
||||
project: Option<Arc<ProjectSnapshot>>,
|
||||
system_fonts: Option<Result<Vec<named_fonts::NamedFace>, String>>,
|
||||
@@ -777,6 +779,7 @@ impl FileWorld {
|
||||
live_paths: BTreeSet::new(),
|
||||
staged_generated: BTreeMap::new(),
|
||||
protected_paths: BTreeSet::new(),
|
||||
project_path_keys: OnceLock::new(),
|
||||
replay_gaps: Vec::new(),
|
||||
project: None,
|
||||
system_fonts: None,
|
||||
@@ -828,6 +831,7 @@ impl FileWorld {
|
||||
live_paths,
|
||||
staged_generated: BTreeMap::new(),
|
||||
protected_paths: BTreeSet::new(),
|
||||
project_path_keys: OnceLock::new(),
|
||||
replay_gaps: Vec::new(),
|
||||
project: Some(project),
|
||||
system_fonts: None,
|
||||
@@ -857,7 +861,7 @@ impl FileWorld {
|
||||
pub fn check_generated_output(&self, logical: &Path, physical: &Path) -> Result<(), String> {
|
||||
if let Some(project) = &self.project {
|
||||
self.check_artifact_output(physical)?;
|
||||
project.check_generated_output(logical, physical, &self.project_paths())?;
|
||||
project.check_generated_output(logical, physical, self.project_paths())?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -866,8 +870,8 @@ impl FileWorld {
|
||||
pub fn generated_output_path(&self, logical: &Path) -> Result<PathBuf, String> {
|
||||
if let Some(project) = &self.project {
|
||||
let known = self.project_paths();
|
||||
let target = project.locate(logical, &known)?.path;
|
||||
project.check_generated_output(logical, &target, &known)?;
|
||||
let target = project.locate(logical, known)?.path;
|
||||
project.check_generated_output(logical, &target, known)?;
|
||||
self.check_artifact_output(&target)?;
|
||||
Ok(target)
|
||||
} else {
|
||||
@@ -919,6 +923,7 @@ impl FileWorld {
|
||||
.unwrap_or_default(),
|
||||
staged_generated: BTreeMap::new(),
|
||||
protected_paths: BTreeSet::new(),
|
||||
project_path_keys: OnceLock::new(),
|
||||
replay_gaps: Vec::new(),
|
||||
project: snapshot.project.clone(),
|
||||
system_fonts: snapshot.system_fonts.clone(),
|
||||
@@ -961,6 +966,7 @@ impl FileWorld {
|
||||
));
|
||||
}
|
||||
if self.live_paths.insert(path.to_owned()) && self.project.is_some() {
|
||||
self.project_path_keys.take();
|
||||
self.current_project_indexes.clear();
|
||||
}
|
||||
}
|
||||
@@ -986,6 +992,9 @@ impl FileWorld {
|
||||
if self.pinned {
|
||||
if was_live || self.project.is_some() {
|
||||
let newly_protected = self.protected_paths.insert(resource.version.path.clone());
|
||||
if was_live || newly_protected {
|
||||
self.project_path_keys.take();
|
||||
}
|
||||
if self.project.as_ref().is_some_and(|project| {
|
||||
was_live || (newly_protected && project.file(&resource.version.path).is_none())
|
||||
}) {
|
||||
@@ -1063,11 +1072,19 @@ impl FileWorld {
|
||||
pub fn generated_storage<'a>(&'a self, path: &'a Path) -> &'a Path {
|
||||
self.staged_generated.get(path).map_or(path, PathBuf::as_path)
|
||||
}
|
||||
fn project_paths(&self) -> BTreeSet<PathBuf> {
|
||||
self.live_paths
|
||||
.union(&self.protected_paths)
|
||||
.cloned()
|
||||
.collect()
|
||||
fn project_paths(&self) -> &BTreeSet<PathBuf> {
|
||||
if self.protected_paths.is_empty() {
|
||||
&self.live_paths
|
||||
} else if self.live_paths.is_empty() {
|
||||
&self.protected_paths
|
||||
} else {
|
||||
self.project_path_keys.get_or_init(|| {
|
||||
self.live_paths
|
||||
.union(&self.protected_paths)
|
||||
.cloned()
|
||||
.collect()
|
||||
})
|
||||
}
|
||||
}
|
||||
fn probe(&mut self, path: &Path) -> Result<Option<PathBuf>, String> {
|
||||
// PathBuf equality drops `/.` and trailing separators. Such spellings
|
||||
@@ -1085,7 +1102,7 @@ impl FileWorld {
|
||||
return Self::existing(path);
|
||||
}
|
||||
if let Some(project) = &self.project {
|
||||
let location = project.locate(path, &self.project_paths())?;
|
||||
let location = project.locate(path, self.project_paths())?;
|
||||
let result = if location.kind == Some(project::NodeKind::File) {
|
||||
if self.live_paths.contains(&location.path) {
|
||||
if let Some(storage) = self.staged_generated.get(&location.path) {
|
||||
@@ -1454,7 +1471,7 @@ impl FileWorld {
|
||||
|| (recursive && !self.indexes[root].recursive)
|
||||
{
|
||||
let index =
|
||||
project.index(root, &self.project_paths(), self.config.max_index_entries, recursive)?;
|
||||
project.index(root, self.project_paths(), self.config.max_index_entries, recursive)?;
|
||||
self.indexes.insert(root.into(), Arc::new(index));
|
||||
self.current_project_indexes.insert(root.into());
|
||||
}
|
||||
|
||||
@@ -447,6 +447,8 @@ fn protected_generated_resources_keep_alias_and_recursive_visibility_without_cac
|
||||
vec![SearchPath::directory(p.join("gen"), true)],
|
||||
);
|
||||
d.generated.insert(p.join("gen/nested/initial.tfm"));
|
||||
// Retain a live key while the earlier resource is promoted and the next one is added.
|
||||
d.generated.insert(p.join("gen/nested/kept-live.tfm"));
|
||||
d.aliases
|
||||
.insert(p.join("again.tfm"), "gen/nested/initial.tfm".into());
|
||||
d.aliases
|
||||
|
||||
Reference in new issue
Block a user