Commit c5f51c26 authored by Mikhail Glushenkov's avatar Mikhail Glushenkov
Browse files

Force-update the cache in 'add-source'/'remove-source'.

Fixes #2060.
parent 8eee043f
...@@ -21,6 +21,7 @@ module Distribution.Client.IndexUtils ( ...@@ -21,6 +21,7 @@ module Distribution.Client.IndexUtils (
parsePackageIndex, parsePackageIndex,
readRepoIndex, readRepoIndex,
updateRepoIndexCache, updateRepoIndexCache,
updatePackageIndexCacheFile,
BuildTreeRefType(..), refTypeFromTypeCode, typeCodeFromRefType BuildTreeRefType(..), refTypeFromTypeCode, typeCodeFromRefType
) where ) where
......
...@@ -22,6 +22,7 @@ import qualified Distribution.Client.Tar as Tar ...@@ -22,6 +22,7 @@ import qualified Distribution.Client.Tar as Tar
import Distribution.Client.IndexUtils ( BuildTreeRefType(..) import Distribution.Client.IndexUtils ( BuildTreeRefType(..)
, refTypeFromTypeCode , refTypeFromTypeCode
, typeCodeFromRefType , typeCodeFromRefType
, updatePackageIndexCacheFile
, getSourcePackagesStrict ) , getSourcePackagesStrict )
import Distribution.Client.PackageIndex ( allPackages ) import Distribution.Client.PackageIndex ( allPackages )
import Distribution.Client.Types ( Repo(..), LocalRepo(..) import Distribution.Client.Types ( Repo(..), LocalRepo(..)
...@@ -43,7 +44,8 @@ import Data.Maybe ( catMaybes ) ...@@ -43,7 +44,8 @@ import Data.Maybe ( catMaybes )
import System.Directory ( createDirectoryIfMissing, import System.Directory ( createDirectoryIfMissing,
doesDirectoryExist, doesFileExist, doesDirectoryExist, doesFileExist,
renameFile ) renameFile )
import System.FilePath ( (</>), (<.>), takeDirectory, takeExtension ) import System.FilePath ( (</>), (<.>), takeDirectory, takeExtension
, replaceExtension )
import System.IO ( IOMode(..), SeekMode(..) import System.IO ( IOMode(..), SeekMode(..)
, hSeek, withBinaryFile ) , hSeek, withBinaryFile )
...@@ -150,6 +152,8 @@ addBuildTreeRefs verbosity path l' refType = do ...@@ -150,6 +152,8 @@ addBuildTreeRefs verbosity path l' refType = do
hSeek h AbsoluteSeek (fromIntegral offset) hSeek h AbsoluteSeek (fromIntegral offset)
BS.hPut h (Tar.write entries) BS.hPut h (Tar.write entries)
debug verbosity $ "Successfully appended to '" ++ path ++ "'" debug verbosity $ "Successfully appended to '" ++ path ++ "'"
updatePackageIndexCacheFile verbosity path
(path `replaceExtension` "cache")
-- | Remove given local build tree references from the index. -- | Remove given local build tree references from the index.
removeBuildTreeRefs :: Verbosity -> FilePath -> [FilePath] -> IO [FilePath] removeBuildTreeRefs :: Verbosity -> FilePath -> [FilePath] -> IO [FilePath]
...@@ -164,10 +168,10 @@ removeBuildTreeRefs verbosity path l' = do ...@@ -164,10 +168,10 @@ removeBuildTreeRefs verbosity path l' = do
-- much smaller. -- much smaller.
BS.writeFile tmpFile . Tar.writeEntries . Tar.filterEntries (p l) . Tar.read BS.writeFile tmpFile . Tar.writeEntries . Tar.filterEntries (p l) . Tar.read
=<< BS.readFile path =<< BS.readFile path
-- This invalidates the cache, so we don't have to update it explicitly.
renameFile tmpFile path renameFile tmpFile path
debug verbosity $ "Successfully renamed '" ++ tmpFile debug verbosity $ "Successfully renamed '" ++ tmpFile
++ "' to '" ++ path ++ "'" ++ "' to '" ++ path ++ "'"
updatePackageIndexCacheFile verbosity path (path `replaceExtension` "cache")
-- FIXME: return only the refs that vere actually removed. -- FIXME: return only the refs that vere actually removed.
return l return l
where where
......
Supports Markdown
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