Skip to content

Commit 2528f73

Browse files
committed
Create noindex.cache if missing
1 parent 333782e commit 2528f73

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
@@ -1167,23 +1167,27 @@ readIndexCache verbosity index = do
11671167
-- 'dieWithException's if it fails again). Throws IOException if any arise.
11681168
readNoIndexCache :: Verbosity -> Index -> IO NoIndexCache
11691169
readNoIndexCache verbosity index = do
1170-
cacheOrFail <- readNoIndexCache' index
1170+
cacheOrFail <- readNoIndexCache' verbosity index
11711171
case cacheOrFail of
11721172
Left msg -> do
11731173
warn verbosity $
11741174
concat
1175-
[ "Parsing the index cache failed ("
1175+
[ "Parsing the index cache for repo \""
1176+
, unRepoName (repoName repo)
1177+
, "\" failed ("
11761178
, msg
11771179
, "). "
11781180
, "Trying to regenerate the index cache..."
11791181
]
11801182

11811183
updatePackageIndexCacheFile verbosity index
11821184

1183-
either (dieWithException verbosity . CorruptedIndexCache) return =<< readNoIndexCache' index
1185+
either (dieWithException verbosity . CorruptedIndexCache) return =<< readNoIndexCache' verbosity index
11841186

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

11881192
-- | Read the 'Index' cache from the filesystem. Throws IO exceptions
11891193
-- if any arise and returns Left on invalid input.
@@ -1194,8 +1198,12 @@ readIndexCache' index
11941198
| otherwise =
11951199
Right . read00IndexCache <$> BSS.readFile (cacheFile index)
11961200

1197-
readNoIndexCache' :: Index -> IO (Either String NoIndexCache)
1198-
readNoIndexCache' index = structuredDecodeFileOrFail (cacheFile index)
1201+
readNoIndexCache' :: Verbosity -> Index -> IO (Either String NoIndexCache)
1202+
readNoIndexCache' verbosity index = do
1203+
exists <- doesFileExist (cacheFile index)
1204+
if exists
1205+
then structuredDecodeFileOrFail (cacheFile index)
1206+
else updatePackageIndexCacheFile verbosity index >> readNoIndexCache' verbosity index
11991207

12001208
-- | Write the 'Index' cache to the filesystem
12011209
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)