@@ -1167,23 +1167,27 @@ readIndexCache verbosity index = do
1167
1167
-- 'dieWithException's if it fails again). Throws IOException if any arise.
1168
1168
readNoIndexCache :: Verbosity -> Index -> IO NoIndexCache
1169
1169
readNoIndexCache verbosity index = do
1170
- cacheOrFail <- readNoIndexCache' index
1170
+ cacheOrFail <- readNoIndexCache' verbosity index
1171
1171
case cacheOrFail of
1172
1172
Left msg -> do
1173
1173
warn verbosity $
1174
1174
concat
1175
- [ " Parsing the index cache failed ("
1175
+ [ " Parsing the index cache for repo \" "
1176
+ , unRepoName (repoName repo)
1177
+ , " \" failed ("
1176
1178
, msg
1177
1179
, " ). "
1178
1180
, " Trying to regenerate the index cache..."
1179
1181
]
1180
1182
1181
1183
updatePackageIndexCacheFile verbosity index
1182
1184
1183
- either (dieWithException verbosity . CorruptedIndexCache ) return =<< readNoIndexCache' index
1185
+ either (dieWithException verbosity . CorruptedIndexCache ) return =<< readNoIndexCache' verbosity index
1184
1186
1185
1187
-- we don't hash cons local repository cache, they are hopefully small
1186
1188
Right res -> return res
1189
+ where
1190
+ RepoIndex _ctxt repo = index
1187
1191
1188
1192
-- | Read the 'Index' cache from the filesystem. Throws IO exceptions
1189
1193
-- if any arise and returns Left on invalid input.
@@ -1194,8 +1198,12 @@ readIndexCache' index
1194
1198
| otherwise =
1195
1199
Right . read00IndexCache <$> BSS. readFile (cacheFile index)
1196
1200
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
1199
1207
1200
1208
-- | Write the 'Index' cache to the filesystem
1201
1209
writeIndexCache :: Index -> Cache -> IO ()
0 commit comments