From 8047bba5b92a6f77ef305c1a74e59b5dacbcc9a2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 7 Dec 2011 16:53:53 -0400 Subject: add: If interrupted, add can leave files converted to symlinks but not yet added to git. Running the add again will now clean up this situtation. --- Command/Add.hs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'Command/Add.hs') diff --git a/Command/Add.hs b/Command/Add.hs index 9fdbdcaa6..9410601b8 100644 --- a/Command/Add.hs +++ b/Command/Add.hs @@ -29,13 +29,21 @@ seek = [withFilesNotInGit start, withFilesUnlocked start] - moving it into the annex directory and setting up the symlink pointing - to its content. -} start :: BackendFile -> CommandStart -start p@(_, file) = notBareRepo $ notAnnexed file $ do - s <- liftIO $ getSymbolicLinkStatus file - if isSymbolicLink s || not (isRegularFile s) - then stop - else do +start p@(_, file) = notBareRepo $ ifAnnexed file fixup add + where + add = do + s <- liftIO $ getSymbolicLinkStatus file + if isSymbolicLink s || not (isRegularFile s) + then stop + else do + showStart "add" file + next $ perform p + fixup (key, _) = do + -- fixup from an interrupted add; the symlink + -- is present but not yet added to git showStart "add" file - next $ perform p + liftIO $ removeFile file + next $ next $ cleanup file key =<< inAnnex key perform :: BackendFile -> CommandPerform perform (backend, file) = Backend.genKey file backend >>= go -- cgit v1.2.3