summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-01-12 01:57:49 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-01-12 01:57:49 -0400
commitbb4a45f9ce9ea3b5b024bc6e46ab61b7b493de9b (patch)
tree8c8e0a68551ce81ffbf8cf3882853e8691fc61cb /Command
parentba6727f66342e59b7e420f102548db5c9a49c6b3 (diff)
avoid crashing if run before unused log is present
Diffstat (limited to 'Command')
-rw-r--r--Command/DropUnused.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/Command/DropUnused.hs b/Command/DropUnused.hs
index ea2ff46eb..cfd6fc3d0 100644
--- a/Command/DropUnused.hs
+++ b/Command/DropUnused.hs
@@ -9,6 +9,7 @@ module Command.DropUnused where
import Control.Monad.State (liftIO)
import qualified Data.Map as M
+import System.Directory
import Command
import Types
@@ -39,8 +40,13 @@ start s = do
readUnusedLog :: Annex (M.Map String Key)
readUnusedLog = do
g <- Annex.gitRepo
- l <- liftIO $ readFile (annexUnusedLog g)
- return $ M.fromList $ map parse $ lines l
+ let f = annexUnusedLog g
+ e <- liftIO $ doesFileExist f
+ if e
+ then do
+ l <- liftIO $ readFile f
+ return $ M.fromList $ map parse $ lines l
+ else return $ M.empty
where
parse line = (head ws, tokey $ unwords $ tail ws)
where