sbuild options: unshare, build directory context: retrieve files
This commit is contained in:
@@ -18,6 +18,8 @@ pub trait CommandRunner {
|
||||
|
||||
pub trait ContextDriver {
|
||||
fn ensure_available(&self, src: &Path, dest_root: &str) -> io::Result<PathBuf>;
|
||||
fn retrieve_path(&self, src: &Path, dest: &Path) -> io::Result<()>;
|
||||
fn list_files(&self, path: &Path) -> io::Result<Vec<PathBuf>>;
|
||||
fn create_runner(&self, program: String) -> Box<dyn CommandRunner>;
|
||||
fn prepare_work_dir(&self) -> io::Result<String>;
|
||||
}
|
||||
@@ -60,6 +62,19 @@ impl Context {
|
||||
self.driver().prepare_work_dir()
|
||||
}
|
||||
|
||||
/// Retrieve a file or directory from the context to the local filesystem.
|
||||
///
|
||||
/// The `src` path is on the context, `dest` is on the local machine.
|
||||
/// If `src` is a directory, it is copied recursively.
|
||||
pub fn retrieve_path(&self, src: &Path, dest: &Path) -> io::Result<()> {
|
||||
self.driver().retrieve_path(src, dest)
|
||||
}
|
||||
|
||||
/// List files in a directory on the context.
|
||||
pub fn list_files(&self, path: &Path) -> io::Result<Vec<PathBuf>> {
|
||||
self.driver().list_files(path)
|
||||
}
|
||||
|
||||
fn driver(&self) -> Box<dyn ContextDriver> {
|
||||
match self {
|
||||
Context::Local => Box::new(LocalDriver),
|
||||
|
||||
Reference in New Issue
Block a user