avoid crashing if run before unused log is present
This commit is contained in:
parent
ba6727f663
commit
bb4a45f9ce
1 changed files with 8 additions and 2 deletions
|
@ -9,6 +9,7 @@ module Command.DropUnused where
|
||||||
|
|
||||||
import Control.Monad.State (liftIO)
|
import Control.Monad.State (liftIO)
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
import System.Directory
|
||||||
|
|
||||||
import Command
|
import Command
|
||||||
import Types
|
import Types
|
||||||
|
@ -39,8 +40,13 @@ start s = do
|
||||||
readUnusedLog :: Annex (M.Map String Key)
|
readUnusedLog :: Annex (M.Map String Key)
|
||||||
readUnusedLog = do
|
readUnusedLog = do
|
||||||
g <- Annex.gitRepo
|
g <- Annex.gitRepo
|
||||||
l <- liftIO $ readFile (annexUnusedLog g)
|
let f = annexUnusedLog g
|
||||||
|
e <- liftIO $ doesFileExist f
|
||||||
|
if e
|
||||||
|
then do
|
||||||
|
l <- liftIO $ readFile f
|
||||||
return $ M.fromList $ map parse $ lines l
|
return $ M.fromList $ map parse $ lines l
|
||||||
|
else return $ M.empty
|
||||||
where
|
where
|
||||||
parse line = (head ws, tokey $ unwords $ tail ws)
|
parse line = (head ws, tokey $ unwords $ tail ws)
|
||||||
where
|
where
|
||||||
|
|
Loading…
Reference in a new issue