Skip to content

Commit 667525f

Browse files
jasagredoMikolaj
authored andcommitted
Create noindex.cache if missing
(cherry picked from commit 2528f73)
1 parent 36e2364 commit 667525f

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

cabal-install/src/Distribution/Client/IndexUtils.hs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,23 +1115,27 @@ readIndexCache verbosity index = do
11151115
-- 'dieWithException's if it fails again). Throws IOException if any arise.
11161116
readNoIndexCache :: Verbosity -> Index -> IO NoIndexCache
11171117
readNoIndexCache verbosity index = do
1118-
cacheOrFail <- readNoIndexCache' index
1118+
cacheOrFail <- readNoIndexCache' verbosity index
11191119
case cacheOrFail of
11201120
Left msg -> do
11211121
warn verbosity $
11221122
concat
1123-
[ "Parsing the index cache failed ("
1123+
[ "Parsing the index cache for repo \""
1124+
, unRepoName (repoName repo)
1125+
, "\" failed ("
11241126
, msg
11251127
, "). "
11261128
, "Trying to regenerate the index cache..."
11271129
]
11281130

11291131
updatePackageIndexCacheFile verbosity index
11301132

1131-
either (dieWithException verbosity . CorruptedIndexCache) return =<< readNoIndexCache' index
1133+
either (dieWithException verbosity . CorruptedIndexCache) return =<< readNoIndexCache' verbosity index
11321134

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

11361140
-- | Read the 'Index' cache from the filesystem. Throws IO exceptions
11371141
-- if any arise and returns Left on invalid input.
@@ -1142,8 +1146,12 @@ readIndexCache' index
11421146
| otherwise =
11431147
Right . read00IndexCache <$> BSS.readFile (cacheFile index)
11441148

1145-
readNoIndexCache' :: Index -> IO (Either String NoIndexCache)
1146-
readNoIndexCache' index = structuredDecodeFileOrFail (cacheFile index)
1149+
readNoIndexCache' :: Verbosity -> Index -> IO (Either String NoIndexCache)
1150+
readNoIndexCache' verbosity index = do
1151+
exists <- doesFileExist (cacheFile index)
1152+
if exists
1153+
then structuredDecodeFileOrFail (cacheFile index)
1154+
else updatePackageIndexCacheFile verbosity index >> readNoIndexCache' verbosity index
11471155

11481156
-- | Write the 'Index' cache to the filesystem
11491157
writeIndexCache :: Index -> Cache -> IO ()

changelog.d/pr-10730

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
synopsis: Create `noindex.cache` file if missing
2+
packages: cabal-install
3+
prs: #10730
4+
issues: #9891
5+
significance:
6+
7+
description: {
8+
9+
- Local+noindex repositories will have their `noindex.cache` file created the first time they are accessed.
10+
11+
}

0 commit comments

Comments
 (0)