LIB: restructure copyDir
This commit is contained in:
parent
0f1c8dafe8
commit
51fffabe22
@ -101,7 +101,22 @@ 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
|
||||||
|
|
||||||
|
newDest <- zipLazy mkDirInfo mkFileInfo destdir
|
||||||
|
|
||||||
|
for_ (goAllDown from) $ \f ->
|
||||||
|
-- TODO: maybe do this strict?
|
||||||
|
case f of
|
||||||
|
-- recreate symlink
|
||||||
|
sz@(Dir { name = n, dir = (DirInfo { sym = True }) }, _) ->
|
||||||
|
recreateSymlink newDest n sz
|
||||||
|
sz@(Dir {}, _) ->
|
||||||
|
copyDir cm sz newDest
|
||||||
|
sz@(File {}, _) ->
|
||||||
|
copyFileToDir sz newDest
|
||||||
|
where
|
||||||
|
createDestdir destdir =
|
||||||
case cm of
|
case cm of
|
||||||
Merge ->
|
Merge ->
|
||||||
createDirectoryIfMissing False destdir
|
createDirectoryIfMissing False destdir
|
||||||
@ -111,29 +126,18 @@ copyDir cm from@(Dir fn _ _, _) to@(Dir {}, _) = do
|
|||||||
Replace -> do
|
Replace -> do
|
||||||
whenM (doesDirectoryExist destdir) (removeDirectoryRecursive destdir)
|
whenM (doesDirectoryExist destdir) (removeDirectoryRecursive destdir)
|
||||||
createDirectory destdir
|
createDirectory destdir
|
||||||
|
recreateSymlink newDest n sz = do
|
||||||
newDest <- zipLazy mkDirInfo mkFileInfo destdir
|
|
||||||
|
|
||||||
for_ (goAllDown from) $ \f ->
|
|
||||||
-- TODO: maybe do this strict?
|
|
||||||
case f of
|
|
||||||
-- recreate symlink
|
|
||||||
sz@(Dir { name = n, dir = (DirInfo { sym = True }) }, _) -> do
|
|
||||||
let sympoint = getFullPath newDest </> n
|
let sympoint = getFullPath newDest </> n
|
||||||
|
|
||||||
-- delete old file/dir to be able to create symlink
|
|
||||||
case cm of
|
case cm of
|
||||||
Merge ->
|
Merge ->
|
||||||
|
-- delete old file/dir to be able to create symlink
|
||||||
for_ (goDown n newDest) $ \odtz ->
|
for_ (goDown n newDest) $ \odtz ->
|
||||||
easyDelete odtz
|
easyDelete odtz
|
||||||
_ -> return ()
|
_ -> return ()
|
||||||
|
|
||||||
symname <- readSymbolicLink (getFullPath sz)
|
symname <- readSymbolicLink (getFullPath sz)
|
||||||
createSymbolicLink symname sympoint
|
createSymbolicLink symname sympoint
|
||||||
sz@(Dir {}, _) ->
|
|
||||||
copyDir cm sz newDest
|
|
||||||
sz@(File {}, _) ->
|
|
||||||
copyFileToDir sz newDest
|
|
||||||
|
|
||||||
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