Commit 5fb9cd39 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Don't report errors on cleaning when it's already clean

We now ignore file not found errors when deleting the packages dir.
Otherwise when we clean and then clean again we get an exception since
the directory we're trying to delete has already been deleted.
parent 6f519d7e
......@@ -15,11 +15,15 @@ module Hackage.Clean
) where
import Hackage.Types (ConfigFlags(..))
import Hackage.Utils (fileNotFoundExceptions)
import System.Directory (removeDirectoryRecursive)
import Control.Exception (catchJust)
-- | 'clean' removes all downloaded packages from the {config-dir}\/packages\/ directory.
clean :: ConfigFlags -> IO ()
clean cfg
= removeDirectoryRecursive (configCacheDir cfg)
= catchJust fileNotFoundExceptions
(removeDirectoryRecursive (configCacheDir cfg))
-- The packages dir may not exist if it's already cleaned:
(const (return ()))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment