summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Schreiber <marc.schreiber@aixigo.de>2019-06-01 07:17:25 +0200
committerDoug Tangren <d.tangren@gmail.com>2019-06-01 01:17:25 -0400
commit12ec796a5c9cdc1803f59c85328456538c698cbe (patch)
treefedc6d5482fec671ae35e0448cff2383a00c7b82
parentdd732ad2691c4ffb04506024f991a8cbb5b8034b (diff)
copy_file_into creates sub-directories if required (#171)
-rw-r--r--src/lib.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 4c324ce..669ac42 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -543,8 +543,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,
@@ -558,7 +557,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();
@@ -567,7 +569,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