summaryrefslogtreecommitdiff
path: root/cli/standalone/virtual_fs.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/standalone/virtual_fs.rs')
-rw-r--r--cli/standalone/virtual_fs.rs51
1 files changed, 32 insertions, 19 deletions
diff --git a/cli/standalone/virtual_fs.rs b/cli/standalone/virtual_fs.rs
index ee870611b..fe79477d3 100644
--- a/cli/standalone/virtual_fs.rs
+++ b/cli/standalone/virtual_fs.rs
@@ -94,27 +94,40 @@ impl VfsBuilder {
} else if file_type.is_file() {
self.add_file_at_path(&path)?;
} else if file_type.is_symlink() {
- let target = util::fs::canonicalize_path(&path)
- .with_context(|| format!("Reading symlink {}", path.display()))?;
- if let Err(StripRootError { .. }) = self.add_symlink(&path, &target) {
- if target.is_file() {
- // this may change behavior, so warn the user about it
- log::warn!(
- "Symlink target is outside '{}'. Inlining symlink at '{}' to '{}' as file.",
- self.root_path.display(),
- path.display(),
- target.display(),
- );
- // inline the symlink and make the target file
- let file_bytes = std::fs::read(&target)
- .with_context(|| format!("Reading {}", path.display()))?;
- self.add_file(&path, file_bytes)?;
- } else {
+ match util::fs::canonicalize_path(&path) {
+ Ok(target) => {
+ if let Err(StripRootError { .. }) = self.add_symlink(&path, &target)
+ {
+ if target.is_file() {
+ // this may change behavior, so warn the user about it
+ log::warn!(
+ "{} Symlink target is outside '{}'. Inlining symlink at '{}' to '{}' as file.",
+ crate::colors::yellow("Warning"),
+ self.root_path.display(),
+ path.display(),
+ target.display(),
+ );
+ // inline the symlink and make the target file
+ let file_bytes = std::fs::read(&target)
+ .with_context(|| format!("Reading {}", path.display()))?;
+ self.add_file(&path, file_bytes)?;
+ } else {
+ log::warn!(
+ "{} Symlink target is outside '{}'. Excluding symlink at '{}' with target '{}'.",
+ crate::colors::yellow("Warning"),
+ self.root_path.display(),
+ path.display(),
+ target.display(),
+ );
+ }
+ }
+ }
+ Err(err) => {
log::warn!(
- "Symlink target is outside '{}'. Excluding symlink at '{}' with target '{}'.",
- self.root_path.display(),
+ "{} Failed resolving symlink. Ignoring.\n Path: {}\n Message: {:#}",
+ crate::colors::yellow("Warning"),
path.display(),
- target.display(),
+ err
);
}
}