Skip to content
Permalink
Browse files

copy_file_into creates sub-directories if required

  • Loading branch information...
schrieveslaach committed May 22, 2019
1 parent e5258c8 commit ca93f398651a5a2a7ae5a7982a265acb8d582cc1
Showing with 6 additions and 4 deletions.
  1. +6 −4 src/lib.rs
@@ -539,8 +539,7 @@ impl<'a, 'b> Container<'a, 'b> {
/// Copy a byte slice as file into (see `bytes`) the container.
///
/// The file will be copied at the given location (see `path`) and will be owned by root
/// with access mask 644. The specified `path` parent location must exists, otherwise the
/// creation of the file fails.
/// with access mask 644.
pub fn copy_file_into<P: AsRef<Path>>(
&self,
path: P,
@@ -554,7 +553,10 @@ impl<'a, 'b> Container<'a, 'b> {
header.set_mode(0o0644);
ar.append_data(
&mut header,
path.file_name().map(|f| f.to_str().unwrap()).unwrap(),
path.to_path_buf()
.iter()
.skip(1)
.collect::<std::path::PathBuf>(),
bytes,
)
.unwrap();
@@ -563,7 +565,7 @@ impl<'a, 'b> Container<'a, 'b> {
let body = Some((data, "application/x-tar".parse::<Mime>().unwrap()));

let path_arg = form_urlencoded::Serializer::new(String::new())
.append_pair("path", &path.parent().map(|p| p.to_string_lossy()).unwrap())
.append_pair("path", "/")
.finish();

self.docker

0 comments on commit ca93f39

Please sign in to comment.
You can’t perform that action at this time.