refactor some boilerplate

This commit is contained in:
Joey Hess 2011-05-15 02:02:46 -04:00
parent b400984ddf
commit 56bc3e95ca
31 changed files with 93 additions and 86 deletions

View file

@ -34,19 +34,19 @@ start :: CommandStartBackendFile
start pair@(file, _) = notAnnexed file $ do
s <- liftIO $ getSymbolicLinkStatus file
if (isSymbolicLink s) || (not $ isRegularFile s)
then return Nothing
then stop
else do
showStart "add" file
return $ Just $ perform pair
next $ perform pair
perform :: BackendFile -> CommandPerform
perform (file, backend) = do
stored <- Backend.storeFileKey file backend
case stored of
Nothing -> return Nothing
Nothing -> stop
Just (key, _) -> do
moveAnnex key file
return $ Just $ cleanup file key
next $ cleanup file key
cleanup :: FilePath -> Key -> CommandCleanup
cleanup file key = do