Skip to content

Commit 10e9b3a

Browse files
jansheikkinensylvestre
authored andcommitted
ln: run rustfmt
1 parent cdfc8a5 commit 10e9b3a

File tree

1 file changed

+37
-38
lines changed

1 file changed

+37
-38
lines changed

src/uu/ln/src/ln.rs

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -301,46 +301,45 @@ fn link_files_in_dir(files: &[PathBuf], target_dir: &Path, settings: &Settings)
301301

302302
let mut all_successful = true;
303303
for srcpath in files {
304-
let targetpath =
305-
if settings.no_dereference
306-
&& matches!(settings.overwrite, OverwriteMode::Force)
307-
&& target_dir.is_symlink()
308-
{
309-
// In that case, we don't want to do link resolution
310-
// We need to clean the target
311-
if target_dir.is_file() {
312-
if let Err(e) = fs::remove_file(target_dir) {
313-
show_error!("Could not update {}: {}", target_dir.quote(), e);
314-
};
315-
}
316-
if target_dir.is_dir() {
317-
// Not sure why but on Windows, the symlink can be
318-
// considered as a dir
319-
// See test_ln::test_symlink_no_deref_dir
320-
if let Err(e) = fs::remove_dir(target_dir) {
321-
show_error!("Could not update {}: {}", target_dir.quote(), e);
322-
};
323-
}
324-
target_dir.to_path_buf()
325-
} else {
326-
match srcpath.as_os_str().to_str() {
327-
Some(name) => {
328-
match Path::new(name).file_name() {
329-
Some(basename) => target_dir.join(basename),
330-
// This can be None only for "." or "..". Trying
331-
// to create a link with such name will fail with
332-
// EEXIST, which agrees with the behavior of GNU
333-
// coreutils.
334-
None => target_dir.join(name),
335-
}
336-
}
337-
None => {
338-
show_error!("cannot stat {}: No such file or directory", srcpath.quote());
339-
all_successful = false;
340-
continue;
304+
let targetpath = if settings.no_dereference
305+
&& matches!(settings.overwrite, OverwriteMode::Force)
306+
&& target_dir.is_symlink()
307+
{
308+
// In that case, we don't want to do link resolution
309+
// We need to clean the target
310+
if target_dir.is_file() {
311+
if let Err(e) = fs::remove_file(target_dir) {
312+
show_error!("Could not update {}: {}", target_dir.quote(), e);
313+
};
314+
}
315+
if target_dir.is_dir() {
316+
// Not sure why but on Windows, the symlink can be
317+
// considered as a dir
318+
// See test_ln::test_symlink_no_deref_dir
319+
if let Err(e) = fs::remove_dir(target_dir) {
320+
show_error!("Could not update {}: {}", target_dir.quote(), e);
321+
};
322+
}
323+
target_dir.to_path_buf()
324+
} else {
325+
match srcpath.as_os_str().to_str() {
326+
Some(name) => {
327+
match Path::new(name).file_name() {
328+
Some(basename) => target_dir.join(basename),
329+
// This can be None only for "." or "..". Trying
330+
// to create a link with such name will fail with
331+
// EEXIST, which agrees with the behavior of GNU
332+
// coreutils.
333+
None => target_dir.join(name),
341334
}
342335
}
343-
};
336+
None => {
337+
show_error!("cannot stat {}: No such file or directory", srcpath.quote());
338+
all_successful = false;
339+
continue;
340+
}
341+
}
342+
};
344343

345344
if linked_destinations.contains(&targetpath) {
346345
// If the target file was already created in this ln call, do not overwrite

0 commit comments

Comments
 (0)