Skip to content

Commit 97b167a

Browse files
committed
Fix directory cache
1 parent 99d852f commit 97b167a

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

nativelink-util/src/fs_util.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,14 @@ pub async fn hardlink_directory_tree(src_dir: &Path, dst_dir: &Path) -> Result<(
4848
src_dir.display()
4949
);
5050

51-
error_if!(
52-
dst_dir.exists(),
53-
"Destination directory already exists: {}",
54-
dst_dir.display()
55-
);
56-
57-
// Create the root destination directory
58-
fs::create_dir_all(dst_dir).await.err_tip(|| {
59-
format!(
60-
"Failed to create destination directory: {}",
61-
dst_dir.display()
62-
)
63-
})?;
51+
if !dst_dir.exists() {
52+
fs::create_dir_all(dst_dir).await.err_tip(|| {
53+
format!(
54+
"Failed to create destination directory: {}",
55+
dst_dir.display()
56+
)
57+
})?;
58+
}
6459

6560
// Recursively hardlink the directory tree
6661
hardlink_directory_tree_recursive(src_dir, dst_dir).await
@@ -187,10 +182,7 @@ fn set_readonly_recursive_impl<'a>(
187182
use std::os::unix::fs::PermissionsExt;
188183
let mut perms = metadata.permissions();
189184

190-
// If it's a directory, set to r-xr-xr-x (555)
191-
// If it's a file, set to r--r--r-- (444)
192-
let mode = if metadata.is_dir() { 0o555 } else { 0o444 };
193-
perms.set_mode(mode);
185+
perms.set_readonly(true);
194186

195187
fs::set_permissions(path, perms)
196188
.await

0 commit comments

Comments
 (0)