Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -15,11 +15,15 @@ module Hackage.Clean ...@@ -15,11 +15,15 @@ module Hackage.Clean
) where ) where
import Hackage.Types (ConfigFlags(..)) import Hackage.Types (ConfigFlags(..))
import Hackage.Utils (fileNotFoundExceptions)
import System.Directory (removeDirectoryRecursive) import System.Directory (removeDirectoryRecursive)
import Control.Exception (catchJust)
-- | 'clean' removes all downloaded packages from the {config-dir}\/packages\/ directory. -- | 'clean' removes all downloaded packages from the {config-dir}\/packages\/ directory.
clean :: ConfigFlags -> IO () clean :: ConfigFlags -> IO ()
clean cfg clean cfg
= removeDirectoryRecursive (configCacheDir cfg) = catchJust fileNotFoundExceptions
(removeDirectoryRecursive (configCacheDir cfg))
-- The packages dir may not exist if it's already cleaned:
(const (return ()))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment