From 71c783bf24f2aa4ab911d8279081bcad08951ece Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 4 Jul 2011 16:19:04 -0400 Subject: uninit: Use unannex in --fast mode, to support unannexing multiple files that link to the same content. --- Command/Uninit.hs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'Command') diff --git a/Command/Uninit.hs b/Command/Uninit.hs index 5cb66e83a..1497bbfd1 100644 --- a/Command/Uninit.hs +++ b/Command/Uninit.hs @@ -28,7 +28,15 @@ command = [repoCommand "uninit" paramPath seek "de-initialize git-annex and clean out repository"] seek :: [CommandSeek] -seek = [withFilesInGit Command.Unannex.start, withNothing start] +seek = [withFilesInGit startUnannex, withNothing start] + +startUnannex :: CommandStartString +startUnannex file = do + -- Force fast mode before running unannex. This way, if multiple + -- files link to a key, it will be left in the annex and hardlinked + -- to by each. + Annex.changeState $ \s -> s { Annex.fast = True } + Command.Unannex.start file start :: CommandStartNothing start = next perform @@ -40,12 +48,12 @@ cleanup :: CommandCleanup cleanup = do g <- Annex.gitRepo gitPreCommitHookUnWrite g + mapM_ removeAnnex =<< getKeysPresent + liftIO $ removeDirectoryRecursive (gitAnnexDir g) + -- avoid normal shutdown saveState - liftIO $ do - Git.run g "branch" [Param "-D", Param Branch.name] - removeDirectoryRecursive (gitAnnexDir g) - -- avoid normal shutdown - exitSuccess + liftIO $ Git.run g "branch" [Param "-D", Param Branch.name] + liftIO $ exitSuccess gitPreCommitHookUnWrite :: Git.Repo -> Annex () gitPreCommitHookUnWrite repo = do -- cgit v1.2.3