Skip to content

Commit cf9e727

Browse files
committed
Experiment with never creating directory symlinks
This change is wrong and should never be merged to main, nor otherwise ever be present in any release. The point of this is just to check if anything in the test suite currently catches the creation of file symlinks in a situation where a directory symlink should be created.
1 parent 8d89b86 commit cf9e727

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

gix-fs/src/symlink.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,12 @@ pub fn remove(path: &Path) -> io::Result<()> {
3333

3434
/// Create a new symlink at `link` which points to `original`.
3535
///
36-
/// Note that if a symlink target (the `original`) isn't present on disk, it's assumed to be a
37-
/// file, creating a dangling file symlink. This is similar to a dangling symlink on Unix,
38-
/// which doesn't have to care about the target type though.
36+
/// This temporarily broken implementation is to test the test suite.
37+
/// In real life, we should sometimes create directory symlinks!
38+
/// This change should not be merged and should not appear in any releases!!
3939
#[cfg(windows)]
4040
pub fn create(original: &Path, link: &Path) -> io::Result<()> {
41-
use std::os::windows::fs::{symlink_dir, symlink_file};
42-
// TODO: figure out if links to links count as files or whatever they point at
43-
let orig_abs = link.parent().expect("dir for link").join(original);
44-
let is_dir = match std::fs::metadata(orig_abs) {
45-
Ok(m) => m.is_dir(),
46-
Err(err) if err.kind() == io::ErrorKind::NotFound => false,
47-
Err(err) => return Err(err),
48-
};
49-
if is_dir {
50-
symlink_dir(original, link)
51-
} else {
52-
symlink_file(original, link)
53-
}
41+
std::os::windows::fs::symlink_file(original, link)
5442
}
5543

5644
/// Return true if `err` indicates that a file collision happened, i.e. a symlink couldn't be created as the `link`

0 commit comments

Comments
 (0)