@@ -1115,23 +1115,27 @@ readIndexCache verbosity index = do
1115
1115
-- 'dieWithException's if it fails again). Throws IOException if any arise.
1116
1116
readNoIndexCache :: Verbosity -> Index -> IO NoIndexCache
1117
1117
readNoIndexCache verbosity index = do
1118
- cacheOrFail <- readNoIndexCache' index
1118
+ cacheOrFail <- readNoIndexCache' verbosity index
1119
1119
case cacheOrFail of
1120
1120
Left msg -> do
1121
1121
warn verbosity $
1122
1122
concat
1123
- [ " Parsing the index cache failed ("
1123
+ [ " Parsing the index cache for repo \" "
1124
+ , unRepoName (repoName repo)
1125
+ , " \" failed ("
1124
1126
, msg
1125
1127
, " ). "
1126
1128
, " Trying to regenerate the index cache..."
1127
1129
]
1128
1130
1129
1131
updatePackageIndexCacheFile verbosity index
1130
1132
1131
- either (dieWithException verbosity . CorruptedIndexCache ) return =<< readNoIndexCache' index
1133
+ either (dieWithException verbosity . CorruptedIndexCache ) return =<< readNoIndexCache' verbosity index
1132
1134
1133
1135
-- we don't hash cons local repository cache, they are hopefully small
1134
1136
Right res -> return res
1137
+ where
1138
+ RepoIndex _ctxt repo = index
1135
1139
1136
1140
-- | Read the 'Index' cache from the filesystem. Throws IO exceptions
1137
1141
-- if any arise and returns Left on invalid input.
@@ -1142,8 +1146,12 @@ readIndexCache' index
1142
1146
| otherwise =
1143
1147
Right . read00IndexCache <$> BSS. readFile (cacheFile index)
1144
1148
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
1147
1155
1148
1156
-- | Write the 'Index' cache to the filesystem
1149
1157
writeIndexCache :: Index -> Cache -> IO ()
0 commit comments