Correctly deal with broken symlinks when using --conflict override

https://www.filebot.net/forums/viewtopic.php?f=6&t=6174
This commit is contained in:
Reinhard Pointner 2018-09-02 11:07:08 +07:00
parent 06eb06830d
commit 360486848f
2 changed files with 6 additions and 3 deletions

View File

@ -600,7 +600,7 @@ public class CmdlineOperations implements CmdlineInterface {
destination = resolve(source, destination);
}
if (!destination.equals(source) && destination.exists()) {
if (!destination.equals(source) && existsNoFollowLinks(destination)) {
if (conflictAction == ConflictAction.FAIL) {
throw new CmdlineException(String.format("Failed to process [%s] because [%s] already exists", source, destination));
}

View File

@ -159,6 +159,10 @@ public final class FileUtilities {
return destination.toFile();
}
public static boolean existsNoFollowLinks(File file) {
return Files.exists(file.toPath(), LinkOption.NOFOLLOW_LINKS);
}
public static void delete(File file) throws IOException {
if (file.isDirectory()) {
Files.walkFileTree(file.toPath(), new SimpleFileVisitor<Path>() {
@ -620,8 +624,7 @@ public final class FileUtilities {
/**
* Strip file name of invalid characters
*
* @param filename
* original filename
* @param filename original filename
* @return valid file name stripped of invalid characters
*/
public static String validateFileName(CharSequence filename) {