Skip to content

Commit

Permalink
Create noindex.cache if missing
Browse files Browse the repository at this point in the history
  • Loading branch information
jasagredo committed Jan 9, 2025
1 parent 19c9a86 commit 7a81f34
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cabal-install/src/Distribution/Client/IndexUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,9 @@ readNoIndexCache verbosity index = do
Left msg -> do
warn verbosity $
concat
[ "Parsing the index cache failed ("
[ "Parsing the index cache for repo \""
, unRepoName (repoName repo)
, "\" failed ("
, msg
, "). "
, "Trying to regenerate the index cache..."
Expand All @@ -1189,6 +1191,8 @@ readNoIndexCache verbosity index = do

-- we don't hash cons local repository cache, they are hopefully small
Right res -> return res
where
RepoIndex _ctxt repo = index

-- | Read the 'Index' cache from the filesystem. Throws IO exceptions
-- if any arise and returns Left on invalid input.
Expand All @@ -1200,7 +1204,11 @@ readIndexCache' index
Right . read00IndexCache <$> BSS.readFile (cacheFile index)

readNoIndexCache' :: Index -> IO (Either String NoIndexCache)
readNoIndexCache' index = structuredDecodeFileOrFail (cacheFile index)
readNoIndexCache' index = do
exists <- doesFileExist (cacheFile index)
if exists
then structuredDecodeFileOrFail (cacheFile index)
else pure $ Left "No index cache exists yet"

-- | Write the 'Index' cache to the filesystem
writeIndexCache :: Index -> Cache -> IO ()
Expand Down
11 changes: 11 additions & 0 deletions changelog.d/pr-10730
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
synopsis: Create `noindex.cache` file if missing
packages: cabal-install
prs: #10730
issues: #9891
significance:

description: {

- Local+noindex repositories will have their `noindex.cache` file created the first time they are accessed.

}

0 comments on commit 7a81f34

Please sign in to comment.