mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-19 00:02:03 +00:00
only use symlinks from buntar to job
This commit is contained in:
@@ -454,34 +454,48 @@ pub fn copy_recursively(
|
||||
source: impl AsRef<Path>,
|
||||
destination: impl AsRef<Path>,
|
||||
skip: Option<&Vec<String>>,
|
||||
no_symlink: bool,
|
||||
) -> io::Result<()> {
|
||||
for entry in fs::read_dir(source)? {
|
||||
let entry = entry?;
|
||||
let filetype = entry.file_type()?;
|
||||
let destination = destination.as_ref().join(entry.file_name());
|
||||
if let Some(skip) = skip {
|
||||
if skip.contains(&entry.file_name().to_string_lossy().to_string()) {
|
||||
continue;
|
||||
let mut stack = Vec::new();
|
||||
stack.push((
|
||||
source.as_ref().to_path_buf(),
|
||||
destination.as_ref().to_path_buf(),
|
||||
));
|
||||
|
||||
while let Some((current_source, current_destination)) = stack.pop() {
|
||||
for entry in fs::read_dir(¤t_source)? {
|
||||
let entry = entry?;
|
||||
let filetype = entry.file_type()?;
|
||||
let destination = current_destination.join(entry.file_name());
|
||||
if let Some(skip) = skip {
|
||||
if skip.contains(&entry.file_name().to_string_lossy().to_string()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if filetype.is_dir() {
|
||||
fs::create_dir_all(&destination)?;
|
||||
copy_recursively(entry.path(), &destination, None)?;
|
||||
} else {
|
||||
let original = entry.path();
|
||||
if let Err(e) = fs::hard_link(&original, &destination) {
|
||||
tracing::error!(
|
||||
"Could not hard link {original:?} to {destination:?}, trying symlink: {e:#}"
|
||||
);
|
||||
if let Err(e) = std::os::unix::fs::symlink(&original, &destination) {
|
||||
if filetype.is_dir() {
|
||||
fs::create_dir_all(&destination)?;
|
||||
stack.push((entry.path(), destination));
|
||||
} else {
|
||||
let original = entry.path();
|
||||
if let Err(e) = fs::hard_link(&original, &destination) {
|
||||
tracing::error!(
|
||||
"Could not symlink {original:?} to {destination:?}, copying: {e:#}"
|
||||
"Could not hard link {original:?} to {destination:?}, trying symlink or copy (no_symlink={no_symlink}): {e:#}"
|
||||
);
|
||||
fs::copy(&original, &destination)?;
|
||||
if no_symlink {
|
||||
fs::copy(&original, &destination)?;
|
||||
} else {
|
||||
if let Err(e) = std::os::unix::fs::symlink(&original, &destination) {
|
||||
tracing::error!(
|
||||
"Could not symlink {original:?} to {destination:?}, copying: {e:#}"
|
||||
);
|
||||
fs::copy(&original, &destination)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -562,7 +576,7 @@ pub async fn handle_bun_job(
|
||||
|
||||
#[cfg(unix)]
|
||||
if tokio::fs::metadata(&buntar_path).await.is_ok() {
|
||||
if let Err(e) = copy_recursively(&buntar_path, job_dir, None) {
|
||||
if let Err(e) = copy_recursively(&buntar_path, job_dir, None, false) {
|
||||
tracing::error!("Could not extract buntar: {e:#}");
|
||||
} else {
|
||||
gbuntar_name = Some(buntar_name.clone());
|
||||
@@ -600,6 +614,7 @@ pub async fn handle_bun_job(
|
||||
"shared".to_string(),
|
||||
"bunfig.toml".to_string(),
|
||||
]),
|
||||
true,
|
||||
) {
|
||||
fs::remove_dir_all(&buntar_path)?;
|
||||
tracing::error!("Could not create buntar: {e}");
|
||||
|
||||
Reference in New Issue
Block a user