@@ -222,7 +222,11 @@ runLegacyImport mode logs = do
222
222
Log .info $ formatImportStats $ calculateImportStats legacyRegistry importedIndex
223
223
224
224
Log .info " Sorting packages for upload..."
225
- let indexPackages = ManifestIndex .toSortedArray importedIndex.registryIndex
225
+ let allIndexPackages = ManifestIndex .toSortedArray importedIndex.registryIndex
226
+
227
+ Log .info " Removing packages that previously failed publish"
228
+ indexPackages <- allIndexPackages # Array .filterA \(Manifest { name, version }) ->
229
+ isNothing <$> Cache .get _importCache (PublishFailure name version)
226
230
227
231
allMetadata <- Registry .readAllMetadata
228
232
@@ -287,6 +291,7 @@ runLegacyImport mode logs = do
287
291
, " ----------"
288
292
]
289
293
operation <- mkOperation (Manifest manifest)
294
+
290
295
result <- Except .runExcept $ API .publish source operation
291
296
-- TODO: Some packages will fail because the legacy importer does not
292
297
-- perform all the same validation checks that the publishing flow does.
@@ -297,7 +302,8 @@ runLegacyImport mode logs = do
297
302
case result of
298
303
Left error -> do
299
304
Log .error $ " Failed to publish " <> formatted <> " : " <> error
300
- Right _ ->
305
+ Cache .put _importCache (PublishFailure manifest.name manifest.version) error
306
+ Right _ -> do
301
307
Log .info $ " Published " <> formatted
302
308
303
309
-- | Record all package failures to the 'package-failures.json' file.
@@ -826,21 +832,29 @@ legacyRepoParser = do
826
832
-- | A key type for the storage cache. Only supports packages identified by
827
833
-- | their name and version.
828
834
data ImportCache :: (Type -> Type -> Type ) -> Type -> Type
829
- data ImportCache c a = ImportManifest PackageName RawVersion (c (Either VersionValidationError Manifest ) a )
835
+ data ImportCache c a
836
+ = ImportManifest PackageName RawVersion (c (Either VersionValidationError Manifest ) a )
837
+ | PublishFailure PackageName Version (c String a )
830
838
831
839
instance Functor2 c => Functor (ImportCache c ) where
832
840
map k (ImportManifest name version a) = ImportManifest name version (map2 k a)
841
+ map k (PublishFailure name version a) = PublishFailure name version (map2 k a)
833
842
834
843
instance MemoryEncodable ImportCache where
835
844
encodeMemory = case _ of
836
845
ImportManifest name (RawVersion version) next ->
837
846
Exists .mkExists $ Key (" ImportManifest__" <> PackageName .print name <> " __" <> version) next
847
+ PublishFailure name version next -> do
848
+ Exists .mkExists $ Key (" PublishFailureCache__" <> PackageName .print name <> " __" <> Version .print version) next
838
849
839
850
instance FsEncodable ImportCache where
840
851
encodeFs = case _ of
841
852
ImportManifest name (RawVersion version) next -> do
842
853
let codec = CA.Common .either versionValidationErrorCodec Manifest .codec
843
854
Exists .mkExists $ AsJson (" ImportManifest__" <> PackageName .print name <> " __" <> version) codec next
855
+ PublishFailure name version next -> do
856
+ let codec = CA .string
857
+ Exists .mkExists $ AsJson (" PublishFailureCache__" <> PackageName .print name <> " __" <> Version .print version) codec next
844
858
845
859
type IMPORT_CACHE r = (importCache :: Cache ImportCache | r )
846
860
0 commit comments