@@ -147,10 +147,13 @@ data Log
147
147
| LogHieBios HieBios. Log
148
148
| LogSessionLoadingChanged
149
149
| LogSessionNewLoadedFiles ! [FilePath ]
150
+ | LogSessionReloadOnError FilePath ! [FilePath ]
150
151
deriving instance Show Log
151
152
152
153
instance Pretty Log where
153
154
pretty = \ case
155
+ LogSessionReloadOnError path files ->
156
+ " Reloading file due to error in" <+> pretty path <+> " with files:" <+> pretty files
154
157
LogSessionNewLoadedFiles files ->
155
158
" New loaded files:" <+> pretty files
156
159
LogNoneCradleFound path ->
@@ -649,14 +652,14 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
649
652
| compileTime == runTime -> do
650
653
(results, allNewLoaded) <- session (hieYaml, toNormalizedFilePath' cfp, opts, libDir)
651
654
-- put back to pending que if not listed in the results
652
- -- delete cfp even if ew report No cradle target found for cfp
655
+ -- delete cfp even if we report No cradle target found for the cfp
653
656
let remainPendingFiles = Set. delete cfp $ pendingFiles `Set.difference` allNewLoaded
654
657
let newLoadedT = pendingFiles `Set.intersection` allNewLoaded
655
658
atomically $ forM_ remainPendingFiles (writeTQueue pendingFilesTQueue)
656
659
-- log new loaded files
657
660
logWith recorder Info $ LogSessionNewLoadedFiles $ Set. toList newLoadedT
658
- -- remove the file from error loading files
659
661
atomicModifyIORef' cradle_files (\ xs -> (newLoadedT <> xs,() ))
662
+ -- remove the file from error loading files
660
663
atomicModifyIORef' error_loading_files (\ old -> (old `Set.difference` newLoadedT, () ))
661
664
return results
662
665
| otherwise -> return (([renderPackageSetupException cfp GhcVersionMismatch {.. }], Nothing ),[] )
@@ -711,6 +714,9 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
711
714
modifyVar_ filesMap (const (return HM. empty))
712
715
-- Don't even keep the name cache, we start from scratch here!
713
716
modifyVar_ hscEnvs (const (return Map. empty))
717
+ -- cleanup error loading files and cradle files
718
+ atomicModifyIORef' error_loading_files (\ _ -> (Set. empty,() ))
719
+ atomicModifyIORef' cradle_files (\ _ -> (Set. empty,() ))
714
720
715
721
v <- Map. findWithDefault HM. empty hieYaml <$> readVar fileToFlags
716
722
let cfp = toAbsolutePath file
0 commit comments