From bfcc2f39e5e51a186896d8ea5fd681a669d960f2 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sun, 3 Apr 2016 18:16:38 +0200 Subject: [PATCH] LIB: fix throwSameFile in case fp2 doesn't exist yet --- src/HSFM/FileSystem/Errors.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/HSFM/FileSystem/Errors.hs b/src/HSFM/FileSystem/Errors.hs index f815f83..22e30cd 100644 --- a/src/HSFM/FileSystem/Errors.hs +++ b/src/HSFM/FileSystem/Errors.hs @@ -107,7 +107,12 @@ throwSameFile :: Path Abs -- ^ will be canonicalized -> IO () throwSameFile fp1 fp2 = do fp1' <- fmap P.fromAbs $ P.canonicalizePath fp1 - fp2' <- fmap P.fromAbs $ P.canonicalizePath fp2 + -- TODO: clean this up... if canonicalizing fp2 fails we try to + -- canonicalize `dirname fp2` + fp2' <- catchIOError (fmap P.fromAbs $ P.canonicalizePath fp2) + (\_ -> fmap P.fromAbs + $ (P. P.basename fp2) + <$> (P.canonicalizePath $ P.dirname fp2)) when (equalFilePath fp1' fp2') (throw $ SameFile fp1' fp2')