mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
FIX: The in memory asset cache should no longer canonicalize.
The pseudo relative paths for std libraries won't work with them.
This commit is contained in:
parent
17a9882f40
commit
38fc521e3e
@ -51,18 +51,15 @@ impl MemoryCache {
|
||||
|
||||
impl Cache for MemoryCache {
|
||||
fn has_path(&self, path: &PathBuf) -> Result<bool> {
|
||||
let new_path = path.canonicalize()?;
|
||||
Ok(self.map.contains_key(&new_path))
|
||||
Ok(self.map.contains_key(path))
|
||||
}
|
||||
|
||||
fn get(&self, path: &PathBuf) -> Result<Option<Rc<Val>>> {
|
||||
let new_path = path.canonicalize()?;
|
||||
Ok(self.map.get(&new_path).map(|v| v.clone()))
|
||||
Ok(self.map.get(path).map(|v| v.clone()))
|
||||
}
|
||||
|
||||
fn stash(&mut self, path: PathBuf, asset: Rc<Val>) -> Result<()> {
|
||||
let new_path = path.canonicalize()?;
|
||||
self.map.insert(new_path, asset);
|
||||
self.map.insert(path, asset);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -384,7 +384,6 @@ impl<'a> FileBuilder<'a> {
|
||||
fn eval_import(&self, def: &ImportDef) -> Result<Rc<Val>, Box<dyn Error>> {
|
||||
// Look for a std file first.
|
||||
if def.path.fragment.starts_with("std/") {
|
||||
eprintln!("Processing std lib path: {}", def.path.fragment);
|
||||
if self.std.contains_key(&def.path.fragment) {
|
||||
// Okay then this is a stdlib and it's special.
|
||||
// Introduce a scope so the above borrow is dropped before we modify
|
||||
@ -395,7 +394,7 @@ impl<'a> FileBuilder<'a> {
|
||||
let result = match maybe_asset {
|
||||
Some(v) => v.clone(),
|
||||
None => {
|
||||
let mut b = self.clone_builder(&def.path.fragment);
|
||||
let mut b = self.clone_builder(self.file.clone());
|
||||
b.eval_string(self.std.get(&def.path.fragment).unwrap())?;
|
||||
b.get_outputs_as_val()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user