From 39e4dcebc2ef9376744819f4ed2a6d301c5a00e6 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Thu, 28 Sep 2017 12:21:29 +0200 Subject: [PATCH] Fix symlink/override issues @see https://www.filebot.net/forums/viewtopic.php?f=6&t=5352 --- source/net/filebot/util/FileUtilities.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/source/net/filebot/util/FileUtilities.java b/source/net/filebot/util/FileUtilities.java index 36b0e202..53b87825 100644 --- a/source/net/filebot/util/FileUtilities.java +++ b/source/net/filebot/util/FileUtilities.java @@ -25,6 +25,7 @@ import java.nio.file.AtomicMoveNotSupportedException; import java.nio.file.FileVisitOption; import java.nio.file.FileVisitResult; import java.nio.file.Files; +import java.nio.file.LinkOption; import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; import java.nio.file.StandardCopyOption; @@ -120,14 +121,11 @@ public final class FileUtilities { public static File createRelativeSymlink(File link, File target, boolean relativize) throws IOException { if (relativize) { - // make sure we're working with the full path - link = link.getCanonicalFile(); - target = target.getCanonicalFile(); - + // make sure we're working with the correct full path of the file or link try { - target = link.getParentFile().toPath().relativize(target.toPath()).toFile(); + target = link.toPath().getParent().toRealPath(LinkOption.NOFOLLOW_LINKS).relativize(target.toPath()).toFile(); } catch (Throwable e) { - // unable to relativize link target + log.warning(cause("Unable to relativize link target", e)); } }