LIB: fix bug in throwDestinationInSource

We should only run canoncializePath on dirname, otherwise
realPath will likely fail.
This commit is contained in:
Julian Ospald 2016-04-03 14:33:39 +02:00
parent d8fc529bf1
commit 8c95aa312a
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28

View File

@ -111,11 +111,11 @@ throwSameFile fp1 fp2 = do
throwDestinationInSource :: Path Abs -- ^ will be canonicalized
-> Path Abs -- ^ will be canonicalized
-> Path Abs -- ^ `dirname dest` will be canonicalized
-> IO ()
throwDestinationInSource source dest = do
source' <- P.canonicalizePath source
cDestbase <- fmap P.dirname $ P.canonicalizePath dest
cDestbase <- P.canonicalizePath $ P.dirname dest
let dest' = cDestbase P.</> P.basename dest
when (source' `P.isParentOf` dest')
(throw $ DestinationInSource (P.fromAbs dest') (P.fromAbs source'))