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