Skip to content

Commit 833cc77

Browse files
committed
Create noindex.cache if missing
1 parent 70afe9b commit 833cc77

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,9 @@ readNoIndexCache verbosity index = do
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..."
@@ -1184,6 +1186,8 @@ readNoIndexCache verbosity index = do
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.
@@ -1195,7 +1199,11 @@ readIndexCache' index
11951199
Right . read00IndexCache <$> BSS.readFile (cacheFile index)
11961200

11971201
readNoIndexCache' :: Index -> IO (Either String NoIndexCache)
1198-
readNoIndexCache' index = structuredDecodeFileOrFail (cacheFile index)
1202+
readNoIndexCache' index = do
1203+
exists <- doesFileExist (cacheFile index)
1204+
if exists
1205+
then structuredDecodeFileOrFail (cacheFile index)
1206+
else pure $ Left "No index cache exists yet"
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)