@@ -112,6 +112,22 @@ package enum ConvertActionConverter {
112
112
try outputConsumer. consume ( externalRenderNode: externalRenderNode)
113
113
}
114
114
115
+ let linkHierarchySerializationProblems = Synchronized < [ Problem ] > ( [ ] )
116
+ if FeatureFlags . current. isLinkHierarchySerializationEnabled {
117
+ resultsGroup. async ( queue: resultsSyncQueue) {
118
+ signposter. withIntervalSignpost ( " Serialize link hierarchy " , id: signposter. makeSignpostID ( ) ) {
119
+ do {
120
+ let serializableLinkInformation = try context. linkResolver. localResolver. prepareForSerialization ( bundleID: bundle. id)
121
+ try outputConsumer. consume ( linkResolutionInformation: serializableLinkInformation)
122
+ } catch {
123
+ linkHierarchySerializationProblems. sync {
124
+ recordProblem ( from: error, in: & $0, withIdentifier: " link-resolver " )
125
+ }
126
+ }
127
+ }
128
+ }
129
+ }
130
+
115
131
let renderSignpostHandle = signposter. beginInterval ( " Render " , id: signposter. makeSignpostID ( ) , " Render \( context. knownPages. count) pages " )
116
132
117
133
var conversionProblems : [ Problem ] = context. knownPages. concurrentPerform { identifier, results in
@@ -173,44 +189,25 @@ package enum ConvertActionConverter {
173
189
// Wait for any concurrent updates to complete.
174
190
resultsGroup. wait ( )
175
191
192
+ conversionProblems += linkHierarchySerializationProblems. sync { $0 }
193
+
176
194
signposter. endInterval ( " Render " , renderSignpostHandle)
177
195
178
196
guard !Task. isCancelled else { return [ ] }
179
197
180
198
// Write various metadata
181
- if emitDigest {
199
+ if emitDigest || FeatureFlags . current . isLinkHierarchySerializationEnabled {
182
200
signposter. withIntervalSignpost ( " Emit digest " , id: signposter. makeSignpostID ( ) ) {
183
201
do {
184
202
try outputConsumer. finishedConsumingLinkElementSummaries ( )
185
- try outputConsumer. consume ( indexingRecords: indexingRecords)
186
- try outputConsumer. consume ( assets: assets)
187
- } catch {
188
- recordProblem ( from: error, in: & conversionProblems, withIdentifier: " metadata " )
189
- }
190
- }
191
- }
192
-
193
- if FeatureFlags . current. isLinkHierarchySerializationEnabled {
194
- signposter. withIntervalSignpost ( " Serialize link hierarchy " , id: signposter. makeSignpostID ( ) ) {
195
- do {
196
- let serializableLinkInformation = try context. linkResolver. localResolver. prepareForSerialization ( bundleID: bundle. id)
197
- try outputConsumer. consume ( linkResolutionInformation: serializableLinkInformation)
198
-
199
- if !emitDigest {
200
- try outputConsumer. finishedConsumingLinkElementSummaries ( )
203
+ if emitDigest {
204
+ // Only emit the other digest files if `--emit-digest` is passed
205
+ try outputConsumer. consume ( indexingRecords: indexingRecords)
206
+ try outputConsumer. consume ( assets: assets)
207
+ try ( _Deprecated ( outputConsumer) as ( any _DeprecatedConsumeProblemsAccess ) ) . _consume ( problems: context. problems + conversionProblems)
201
208
}
202
209
} catch {
203
- recordProblem ( from: error, in: & conversionProblems, withIdentifier: " link-resolver " )
204
- }
205
- }
206
- }
207
-
208
- if emitDigest {
209
- signposter. withIntervalSignpost ( " Emit digest " , id: signposter. makeSignpostID ( ) ) {
210
- do {
211
- try ( _Deprecated ( outputConsumer) as ( any _DeprecatedConsumeProblemsAccess ) ) . _consume ( problems: context. problems + conversionProblems)
212
- } catch {
213
- recordProblem ( from: error, in: & conversionProblems, withIdentifier: " problems " )
210
+ recordProblem ( from: error, in: & conversionProblems, withIdentifier: " metadata " )
214
211
}
215
212
}
216
213
}
0 commit comments