Bind native format inputs after moving a project tree
This commit is contained in:
1 parent
c2e1e64a60
commit
1ad9c4db82
8 files changed
+509
-23
No files matched your search
@@ -214,6 +214,8 @@ pub struct ResourceLookup {
|
||||
pub from: PathBuf,
|
||||
pub candidates: Vec<PathBuf>,
|
||||
pub resolved: Option<PathBuf>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub lookup_path: Option<PathBuf>,
|
||||
pub error: Option<String>,
|
||||
}
|
||||
/// Bytes delivered by a stream read, rather than a snapshot of the whole file.
|
||||
@@ -271,6 +273,8 @@ pub struct ResourceTrace {
|
||||
pub texmf_roots: Vec<PathBuf>,
|
||||
pub paths: BTreeMap<ResourceKind, Vec<SearchPath>>,
|
||||
pub lookups: Vec<ResourceLookup>,
|
||||
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
||||
pub format_input_bindings: BTreeMap<PathBuf, PathBuf>,
|
||||
/// Versions of bytes actually read, not hashes guessed from input strings.
|
||||
pub reads: Vec<ResourceVersion>,
|
||||
pub stream_reads: Vec<ResourceReadRange>,
|
||||
@@ -531,6 +535,7 @@ impl InputSnapshot {
|
||||
pub struct FileWorld {
|
||||
config: WorldConfig,
|
||||
tex_suffix_fallback: bool,
|
||||
capture_lookup_paths: bool,
|
||||
indexes: BTreeMap<PathBuf, Arc<DirectoryIndex>>,
|
||||
current_project_indexes: BTreeSet<PathBuf>,
|
||||
index_failures: BTreeMap<PathBuf, DirectoryFailure>,
|
||||
@@ -670,6 +675,7 @@ impl FileWorld {
|
||||
Ok(Self {
|
||||
config,
|
||||
tex_suffix_fallback: true,
|
||||
capture_lookup_paths: false,
|
||||
indexes: BTreeMap::new(),
|
||||
current_project_indexes: BTreeSet::new(),
|
||||
index_failures: BTreeMap::new(),
|
||||
@@ -697,6 +703,11 @@ impl FileWorld {
|
||||
}
|
||||
self.pinned = true;
|
||||
}
|
||||
/// Record the selected lookup spelling for a persisted format's inputs.
|
||||
pub fn capture_lookup_paths(&mut self) {
|
||||
self.capture_lookup_paths = true;
|
||||
}
|
||||
|
||||
pub fn from_project(project: Arc<ProjectSnapshot>) -> Result<Self, String> {
|
||||
project.validate()?;
|
||||
let config = project.configuration();
|
||||
@@ -713,6 +724,7 @@ impl FileWorld {
|
||||
Ok(Self {
|
||||
config,
|
||||
tex_suffix_fallback: true,
|
||||
capture_lookup_paths: false,
|
||||
indexes: BTreeMap::new(),
|
||||
current_project_indexes: BTreeSet::new(),
|
||||
index_failures: BTreeMap::new(),
|
||||
@@ -793,6 +805,7 @@ impl FileWorld {
|
||||
Ok(Self {
|
||||
config,
|
||||
tex_suffix_fallback: snapshot.tex_suffix_fallback,
|
||||
capture_lookup_paths: false,
|
||||
indexes: snapshot.indexes.clone(),
|
||||
current_project_indexes: BTreeSet::new(),
|
||||
index_failures: snapshot.index_failures.clone(),
|
||||
@@ -1219,6 +1232,10 @@ impl FileWorld {
|
||||
error
|
||||
})
|
||||
}
|
||||
pub fn record_format_input_bindings(&mut self, bindings: &BTreeMap<PathBuf, PathBuf>) {
|
||||
self.trace.format_input_bindings.clone_from(bindings);
|
||||
}
|
||||
|
||||
pub fn trace(&self) -> &ResourceTrace {
|
||||
&self.trace
|
||||
}
|
||||
@@ -1463,9 +1480,11 @@ impl FileWorld {
|
||||
name: &str,
|
||||
from: &Path,
|
||||
variants: Vec<PathBuf>,
|
||||
mut lookup_path: Option<&mut PathBuf>,
|
||||
lookup_path: Option<&mut PathBuf>,
|
||||
) -> Result<Option<PathBuf>, String> {
|
||||
let mut candidates = Vec::new();
|
||||
let record_spelling = self.capture_lookup_paths || lookup_path.is_some();
|
||||
let mut spelling = None;
|
||||
let result = (|| {
|
||||
let paths = self.paths(kind, from);
|
||||
let mut found = None;
|
||||
@@ -1480,8 +1499,8 @@ impl FileWorld {
|
||||
let path = self.config.cwd.join(variant);
|
||||
candidates.push(path.clone());
|
||||
if let Some(path) = self.probe(&path)? {
|
||||
if let Some(lookup_path) = lookup_path.as_deref_mut() {
|
||||
lookup_path.clone_from(variant);
|
||||
if record_spelling {
|
||||
spelling = Some(variant.clone());
|
||||
}
|
||||
found = Some(path);
|
||||
break;
|
||||
@@ -1516,8 +1535,8 @@ impl FileWorld {
|
||||
let direct = root.join(suffix).join(variant);
|
||||
candidates.push(direct.clone());
|
||||
if let Some(path) = self.probe(&direct)? {
|
||||
if let Some(lookup_path) = lookup_path.as_deref_mut() {
|
||||
*lookup_path = lookup_name(&self.config.cwd, &direct);
|
||||
if record_spelling {
|
||||
spelling = Some(lookup_name(&self.config.cwd, &direct));
|
||||
}
|
||||
found = Some(path);
|
||||
break 'paths;
|
||||
@@ -1573,8 +1592,8 @@ impl FileWorld {
|
||||
}
|
||||
candidates.push(candidate.clone());
|
||||
if let Some(path) = self.probe(&candidate)? {
|
||||
if let Some(lookup_path) = lookup_path.as_deref_mut() {
|
||||
*lookup_path = lookup_name(&self.config.cwd, &candidate);
|
||||
if record_spelling {
|
||||
spelling = Some(lookup_name(&self.config.cwd, &candidate));
|
||||
}
|
||||
found = Some(path);
|
||||
break 'paths;
|
||||
@@ -1586,12 +1605,18 @@ impl FileWorld {
|
||||
}
|
||||
Ok(found)
|
||||
})();
|
||||
if let Some(lookup_path) = lookup_path
|
||||
&& let Some(selected) = &spelling
|
||||
{
|
||||
lookup_path.clone_from(selected);
|
||||
}
|
||||
self.trace.lookups.push(ResourceLookup {
|
||||
kind,
|
||||
name: name.into(),
|
||||
from: from.into(),
|
||||
candidates,
|
||||
resolved: result.as_ref().ok().cloned().flatten(),
|
||||
lookup_path: spelling.filter(|_| self.capture_lookup_paths),
|
||||
error: result.as_ref().err().cloned(),
|
||||
});
|
||||
result
|
||||
|
||||
Reference in new issue
Block a user