@@ -259,14 +259,15 @@ export default class ProjectService implements IProjectService {
259
259
try {
260
260
const blobs = new Set < string > ( await storageProvider . listFiles ( project . folderPath ) ) ;
261
261
const assetLabel = asset ? asset + constants . labelFileExtension : undefined ;
262
- for ( const blob of blobs ) {
262
+ await Promise . all ( Array . from ( blobs ) . map ( async ( blob ) => {
263
263
const blobFolderPath = blob . substr ( 0 , blob . lastIndexOf ( "/" ) ) ;
264
264
if ( blobFolderPath === project . folderPath
265
265
&& blob . endsWith ( constants . labelFileExtension )
266
266
&& blobs . has ( blob . substr ( 0 , blob . length - constants . labelFileExtension . length ) ) ) {
267
267
try {
268
268
if ( ! assetLabel || assetLabel === blob ) {
269
269
const content = JSON . parse ( await storageProvider . readText ( blob ) ) as ILabelData ;
270
+ const localTagDocumentCount = { } ;
270
271
content . labels . forEach ( ( label ) => {
271
272
if ( constants . supportedLabelsSchemas . has ( content ?. $schema ) && label . label . split ( "/" ) . length > 1 ) {
272
273
return ;
@@ -277,22 +278,32 @@ export default class ProjectService implements IProjectService {
277
278
} else {
278
279
labelName = label . label
279
280
}
280
- tagNameSet . add ( labelName ) ;
281
- if ( tagDocumentCount [ labelName ] ) {
282
- tagDocumentCount [ labelName ] += 1 ;
281
+ if ( localTagDocumentCount [ labelName ] ) {
282
+ localTagDocumentCount [ labelName ] += 1 ;
283
283
} else {
284
- tagDocumentCount [ labelName ] = 1 ;
284
+ localTagDocumentCount [ labelName ] = 1 ;
285
285
}
286
286
} ) ;
287
- }
288
- if ( assetLabel && assetLabel === blob ) {
289
- break ;
287
+ return localTagDocumentCount ;
290
288
}
291
289
} catch ( err ) {
292
290
// ignore err
293
291
}
294
292
}
295
- }
293
+ } ) ) . then ( localTagDocumentCounts => {
294
+ for ( const localTagDocumentCount of localTagDocumentCounts ) {
295
+ if ( _ . isPlainObject ( localTagDocumentCount ) ) {
296
+ for ( const [ labelName , labelCount ] of Object . entries ( localTagDocumentCount ) ) {
297
+ tagNameSet . add ( labelName ) ;
298
+ if ( tagDocumentCount [ labelName ] ) {
299
+ tagDocumentCount [ labelName ] += labelCount ;
300
+ } else {
301
+ tagDocumentCount [ labelName ] = labelCount ;
302
+ }
303
+ }
304
+ }
305
+ }
306
+ } ) ;
296
307
const tagNameArray = Array . from ( tagNameSet ) ;
297
308
if ( tagNameArray . containsDuplicates ( ( name ) => name ) ) {
298
309
const reason = interpolate (
0 commit comments