LIB: restructure copyDir
This commit is contained in:
parent
0f1c8dafe8
commit
51fffabe22
@ -101,16 +101,7 @@ copyDir cm from@(Dir fn _ _, _) to@(Dir {}, _) = do
|
|||||||
dirSanityThrow top
|
dirSanityThrow top
|
||||||
throwDestinationInSource fromp top
|
throwDestinationInSource fromp top
|
||||||
|
|
||||||
-- what to do with target directory
|
createDestdir destdir
|
||||||
case cm of
|
|
||||||
Merge ->
|
|
||||||
createDirectoryIfMissing False destdir
|
|
||||||
Strict -> do
|
|
||||||
throwDirDoesExist destdir
|
|
||||||
createDirectory destdir
|
|
||||||
Replace -> do
|
|
||||||
whenM (doesDirectoryExist destdir) (removeDirectoryRecursive destdir)
|
|
||||||
createDirectory destdir
|
|
||||||
|
|
||||||
newDest <- zipLazy mkDirInfo mkFileInfo destdir
|
newDest <- zipLazy mkDirInfo mkFileInfo destdir
|
||||||
|
|
||||||
@ -118,22 +109,35 @@ copyDir cm from@(Dir fn _ _, _) to@(Dir {}, _) = do
|
|||||||
-- TODO: maybe do this strict?
|
-- TODO: maybe do this strict?
|
||||||
case f of
|
case f of
|
||||||
-- recreate symlink
|
-- recreate symlink
|
||||||
sz@(Dir { name = n, dir = (DirInfo { sym = True }) }, _) -> do
|
sz@(Dir { name = n, dir = (DirInfo { sym = True }) }, _) ->
|
||||||
let sympoint = getFullPath newDest </> n
|
recreateSymlink newDest n sz
|
||||||
|
|
||||||
-- delete old file/dir to be able to create symlink
|
|
||||||
case cm of
|
|
||||||
Merge ->
|
|
||||||
for_ (goDown n newDest) $ \odtz ->
|
|
||||||
easyDelete odtz
|
|
||||||
_ -> return ()
|
|
||||||
|
|
||||||
symname <- readSymbolicLink (getFullPath sz)
|
|
||||||
createSymbolicLink symname sympoint
|
|
||||||
sz@(Dir {}, _) ->
|
sz@(Dir {}, _) ->
|
||||||
copyDir cm sz newDest
|
copyDir cm sz newDest
|
||||||
sz@(File {}, _) ->
|
sz@(File {}, _) ->
|
||||||
copyFileToDir sz newDest
|
copyFileToDir sz newDest
|
||||||
|
where
|
||||||
|
createDestdir destdir =
|
||||||
|
case cm of
|
||||||
|
Merge ->
|
||||||
|
createDirectoryIfMissing False destdir
|
||||||
|
Strict -> do
|
||||||
|
throwDirDoesExist destdir
|
||||||
|
createDirectory destdir
|
||||||
|
Replace -> do
|
||||||
|
whenM (doesDirectoryExist destdir) (removeDirectoryRecursive destdir)
|
||||||
|
createDirectory destdir
|
||||||
|
recreateSymlink newDest n sz = do
|
||||||
|
let sympoint = getFullPath newDest </> n
|
||||||
|
|
||||||
|
case cm of
|
||||||
|
Merge ->
|
||||||
|
-- delete old file/dir to be able to create symlink
|
||||||
|
for_ (goDown n newDest) $ \odtz ->
|
||||||
|
easyDelete odtz
|
||||||
|
_ -> return ()
|
||||||
|
|
||||||
|
symname <- readSymbolicLink (getFullPath sz)
|
||||||
|
createSymbolicLink symname sympoint
|
||||||
|
|
||||||
copyDir _ from@(File _ _, _) _ = throw $ NotADir (getFullPath from)
|
copyDir _ from@(File _ _, _) _ = throw $ NotADir (getFullPath from)
|
||||||
copyDir _ _ to@(File _ _, _) = throw $ NotADir (getFullPath to)
|
copyDir _ _ to@(File _ _, _) = throw $ NotADir (getFullPath to)
|
||||||
|
Loading…
Reference in New Issue
Block a user