fix: keep a path's bytes, so a filename that is not utf-8 survives
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
use std::ffi::OsString;
|
||||
use std::path::Path;
|
||||
|
||||
use super::{Argv, Cmd};
|
||||
|
||||
// docker exec, around a command that runs inside the container
|
||||
@@ -47,24 +50,25 @@ impl Cmd for Exec {
|
||||
}
|
||||
}
|
||||
|
||||
// docker cp, in either direction
|
||||
// docker cp, in either direction. the local side stays an OsString: it is a
|
||||
// path the user named, and a lossy one would copy something else
|
||||
pub struct Cp {
|
||||
from: String,
|
||||
to: String,
|
||||
from: OsString,
|
||||
to: OsString,
|
||||
}
|
||||
|
||||
impl Cp {
|
||||
pub fn into_container(local: &str, container: &str, remote: &str) -> Self {
|
||||
pub fn into_container(local: &Path, container: &str, remote: &str) -> Self {
|
||||
Self {
|
||||
from: local.to_string(),
|
||||
to: format!("{container}:{remote}"),
|
||||
from: local.as_os_str().to_owned(),
|
||||
to: OsString::from(format!("{container}:{remote}")),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn out_of_container(container: &str, remote: &str, local: &str) -> Self {
|
||||
pub fn out_of_container(container: &str, remote: &str, local: &Path) -> Self {
|
||||
Self {
|
||||
from: format!("{container}:{remote}"),
|
||||
to: local.to_string(),
|
||||
from: OsString::from(format!("{container}:{remote}")),
|
||||
to: local.as_os_str().to_owned(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user