Skip to content

Commit

Permalink
Copy .cargo and .xargo correctly
Browse files Browse the repository at this point in the history
Co-authored-by: josh-bpl <124796608+josh-bpl@users.noreply.github.com>
  • Loading branch information
Emilgardis and josh-bpl committed Feb 10, 2023
1 parent 80c9f91 commit 5666e72
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/docker/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ impl<'a, 'b, 'c> ContainerDataVolume<'a, 'b, 'c> {
mount_prefix: &str,
msg_info: &mut MessageInfo,
) -> Result<ExitStatus> {
if let Some((_, rel)) = reldst.rsplit_once('/') {
if src.is_dir() && src.file_name().unwrap().to_utf8()? == rel {
eyre::bail!(
"reldst is pointing to the wrong path: {} -> {}\n{}",
src.as_posix_relative()?,
reldst,
std::panic::Location::caller()
);
}
}
subcommand_or_exit(self.engine, "cp")?
.arg("-a")
.arg(src.to_utf8()?)
Expand Down Expand Up @@ -196,7 +206,15 @@ impl<'a, 'b, 'c> ContainerDataVolume<'a, 'b, 'c> {
mount_prefix,
msg_info,
)?;
self.copy_files(dirs.xargo(), &reldst, mount_prefix, msg_info)?;
self.copy_files(
dirs.xargo(),
reldst
.rsplit_once('/')
.ok_or_else(|| eyre::eyre!("cargo can't be a root directory"))?
.0,
mount_prefix,
msg_info,
)?;
}

Ok(())
Expand All @@ -216,7 +234,15 @@ impl<'a, 'b, 'c> ContainerDataVolume<'a, 'b, 'c> {
.unwrap_or(copy_registry);

if copy_registry {
self.copy_files(dirs.cargo(), &reldst, mount_prefix, msg_info)?;
self.copy_files(
dirs.cargo(),
reldst
.rsplit_once('/')
.ok_or_else(|| eyre::eyre!("cargo can't be a root directory"))?
.0,
mount_prefix,
msg_info,
)?;
} else {
// can copy a limit subset of files: the rest is present.
self.create_dir(&reldst, mount_prefix, msg_info)?;
Expand Down

0 comments on commit 5666e72

Please sign in to comment.