factor out a stopUnless
code melt for lunch
This commit is contained in:
parent
d64132a43a
commit
3f5f28b487
9 changed files with 69 additions and 107 deletions
|
@ -58,22 +58,18 @@ perform file oldkey newbackend = do
|
|||
cleantmp tmpfile
|
||||
case k of
|
||||
Nothing -> stop
|
||||
Just (newkey, _) -> do
|
||||
ok <- link src newkey
|
||||
if ok
|
||||
then do
|
||||
-- Update symlink to use the new key.
|
||||
liftIO $ removeFile file
|
||||
Just (newkey, _) -> stopUnless (link src newkey) $ do
|
||||
-- Update symlink to use the new key.
|
||||
liftIO $ removeFile file
|
||||
|
||||
-- If the old key had some
|
||||
-- associated urls, record them for
|
||||
-- the new key as well.
|
||||
urls <- getUrls oldkey
|
||||
unless (null urls) $
|
||||
mapM_ (setUrlPresent newkey) urls
|
||||
-- If the old key had some
|
||||
-- associated urls, record them for
|
||||
-- the new key as well.
|
||||
urls <- getUrls oldkey
|
||||
unless (null urls) $
|
||||
mapM_ (setUrlPresent newkey) urls
|
||||
|
||||
next $ Command.Add.cleanup file newkey True
|
||||
else stop
|
||||
next $ Command.Add.cleanup file newkey True
|
||||
where
|
||||
cleantmp t = liftIO $ whenM (doesFileExist t) $ removeFile t
|
||||
link src newkey = getViaTmpUnchecked newkey $ \t -> do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue