@@ -13,13 +13,14 @@ module Stack.Build.Cache
1313 , tryGetFlagCache
1414 , deleteCaches
1515 , markExeInstalled
16+ , markExeNotInstalled
1617 , writeFlagCache
1718 , writeBuildCache
1819 , writeConfigCache
1920 , writeCabalMod
2021 ) where
2122
22- import Control.Exception.Enclosed (handleIO , tryIO )
23+ import Control.Exception.Enclosed (catchIO , handleIO , tryIO )
2324import Control.Monad.Catch (MonadCatch , MonadThrow , catch ,
2425 throwM )
2526import Control.Monad.IO.Class
@@ -42,7 +43,8 @@ import Stack.Package
4243import Stack.Types
4344import System.Directory (createDirectoryIfMissing ,
4445 getDirectoryContents ,
45- getModificationTime )
46+ getModificationTime ,
47+ removeFile )
4648import System.IO.Error (isDoesNotExistError )
4749
4850-- | Directory containing files to mark an executable as installed
@@ -72,6 +74,15 @@ markExeInstalled loc ident = do
7274 -- longer exist
7375 liftIO $ writeFile fp " Installed"
7476
77+ -- | Mark the given executable as not installed
78+ markExeNotInstalled :: (MonadReader env m , HasEnvConfig env , MonadIO m , MonadThrow m )
79+ => InstallLocation -> PackageIdentifier -> m ()
80+ markExeNotInstalled loc ident = do
81+ dir <- exeInstalledDir loc
82+ ident' <- parseRelFile $ packageIdentifierString ident
83+ let fp = toFilePath $ dir </> ident'
84+ liftIO $ catchIO (removeFile fp) (\ _ -> return () )
85+
7586-- | Stored on disk to know whether the flags have changed or any
7687-- files have changed.
7788data BuildCache = BuildCache
0 commit comments