context: copy symlinks as symlinks and improve error messages
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
/// Context driver: Does nothing
|
||||
use super::api::ContextDriver;
|
||||
use std::io;
|
||||
use std::os::unix::fs::symlink;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
use std::time::SystemTime;
|
||||
@@ -112,6 +113,14 @@ impl ContextDriver for LocalDriver {
|
||||
}
|
||||
|
||||
fn copy_dir_recursive(src: &Path, dest: &Path) -> io::Result<()> {
|
||||
// Reproduce symlinks as symlinks rather than following them, so that
|
||||
// dangling/absolute symlinks do not abort the copy.
|
||||
if std::fs::symlink_metadata(src)?.file_type().is_symlink() {
|
||||
let target = std::fs::read_link(src)?;
|
||||
let _ = std::fs::remove_file(dest);
|
||||
return symlink(&target, dest);
|
||||
}
|
||||
|
||||
if src.is_dir() {
|
||||
std::fs::create_dir_all(dest)?;
|
||||
for entry in std::fs::read_dir(src)? {
|
||||
|
||||
Reference in New Issue
Block a user