MCPcopy Create free account
hub / github.com/Qovery/engine / copy_files

Function copy_files

lib-engine/src/fs.rs:17–49  ·  view source on GitHub ↗
(from: &Path, to: &Path, exclude_j2_files: bool)

Source from the content-addressed store, hash-verified

15use walkdir::WalkDir;
16
17pub fn copy_files(from: &Path, to: &Path, exclude_j2_files: bool) -> Result<(), Error> {
18 let files = WalkDir::new(from).follow_links(true).into_iter().filter_map(|e| e.ok());
19
20 let files = match exclude_j2_files {
21 true => files
22 .filter(|e| {
23 // return only non *.j2.* files
24 e.file_name().to_str().map(|s| !s.contains(".j2.")).unwrap_or(false)
25 })
26 .collect::<Vec<_>>(),
27 false => files.collect::<Vec<_>>(),
28 };
29
30 create_dir_all(to)?;
31 let from_str = from.to_string_lossy();
32
33 for file in files {
34 let path_str = file.path().to_string_lossy();
35 let dest = format!(
36 "{}{}",
37 to.to_str().unwrap_or(""),
38 path_str.replace(from_str.as_ref(), "").as_str()
39 );
40
41 if file.metadata()?.is_dir() {
42 create_dir_all(&dest)?;
43 }
44
45 let _ = fs::copy(file.path(), dest);
46 }
47
48 Ok(())
49}
50
51pub fn root_workspace_directory<X, S>(working_root_dir: X, execution_id: S) -> Result<PathBuf, Error>
52where

Callers 1

copy_non_template_filesFunction · 0.85

Calls 2

metadataMethod · 0.80
pathMethod · 0.45

Tested by

no test coverage detected