@@ -34,13 +34,24 @@ export default async function execute(input: CmdRunContext) {
3434 title : `Processing localization tasks ${ chalk . dim (
3535 `(tasks: ${ input . tasks . length } , concurrency: ${ effectiveConcurrency } )` ,
3636 ) } `,
37- task : ( ctx , task ) => {
37+ task : async ( ctx , task ) => {
3838 if ( input . tasks . length < 1 ) {
3939 task . title = `Skipping, nothing to localize.` ;
4040 task . skip ( ) ;
4141 return ;
4242 }
4343
44+ // Preload checksums for all unique bucket path patterns before starting any workers
45+ const initialChecksumsMap = new Map < string , Record < string , string > > ( ) ;
46+ const uniqueBucketPatterns = _ . uniq (
47+ ctx . tasks . map ( ( t ) => t . bucketPathPattern ) ,
48+ ) ;
49+ for ( const bucketPathPattern of uniqueBucketPatterns ) {
50+ const deltaProcessor = createDeltaProcessor ( bucketPathPattern ) ;
51+ const checksums = await deltaProcessor . loadChecksums ( ) ;
52+ initialChecksumsMap . set ( bucketPathPattern , checksums ) ;
53+ }
54+
4455 const i18nLimiter = pLimit ( effectiveConcurrency ) ;
4556 const ioLimiter = pLimit ( 1 ) ;
4657 const workersCount = effectiveConcurrency ;
@@ -56,6 +67,7 @@ export default async function execute(input: CmdRunContext) {
5667 assignedTasks,
5768 ioLimiter,
5869 i18nLimiter,
70+ initialChecksumsMap,
5971 onDone ( ) {
6072 task . title = createExecutionProgressMessage ( ctx ) ;
6173 } ,
@@ -140,6 +152,7 @@ function createWorkerTask(args: {
140152 ioLimiter : LimitFunction ;
141153 i18nLimiter : LimitFunction ;
142154 onDone : ( ) => void ;
155+ initialChecksumsMap : Map < string , Record < string , string > > ;
143156} ) : ListrTask {
144157 return {
145158 title : "Initializing..." ,
@@ -154,6 +167,10 @@ function createWorkerTask(args: {
154167 assignedTask . bucketPathPattern ,
155168 ) ;
156169
170+ // Get initial checksums from the preloaded map
171+ const initialChecksums =
172+ args . initialChecksumsMap . get ( assignedTask . bucketPathPattern ) || { } ;
173+
157174 const taskResult = await args . i18nLimiter ( async ( ) => {
158175 try {
159176 const sourceData = await bucketLoader . pull (
@@ -163,11 +180,10 @@ function createWorkerTask(args: {
163180 const targetData = await bucketLoader . pull (
164181 assignedTask . targetLocale ,
165182 ) ;
166- const checksums = await deltaProcessor . loadChecksums ( ) ;
167183 const delta = await deltaProcessor . calculateDelta ( {
168184 sourceData,
169185 targetData,
170- checksums,
186+ checksums : initialChecksums ,
171187 } ) ;
172188
173189 const processableData = _ . chain ( sourceData )
@@ -193,7 +209,12 @@ function createWorkerTask(args: {
193209 // re-push in case some of the unlocalizable / meta data changed
194210 await bucketLoader . push ( assignedTask . targetLocale , targetData ) ;
195211 } ) ;
196- return { status : "skipped" } satisfies CmdRunTaskResult ;
212+ return {
213+ status : "skipped" ,
214+ pathPattern : assignedTask . bucketPathPattern ,
215+ sourceLocale : assignedTask . sourceLocale ,
216+ targetLocale : assignedTask . targetLocale ,
217+ } satisfies CmdRunTaskResult ;
197218 }
198219
199220 const relevantHints = _ . pick ( hints , Object . keys ( processableData ) ) ;
@@ -268,11 +289,19 @@ function createWorkerTask(args: {
268289 }
269290 } ) ;
270291
271- return { status : "success" } satisfies CmdRunTaskResult ;
292+ return {
293+ status : "success" ,
294+ pathPattern : assignedTask . bucketPathPattern ,
295+ sourceLocale : assignedTask . sourceLocale ,
296+ targetLocale : assignedTask . targetLocale ,
297+ } satisfies CmdRunTaskResult ;
272298 } catch ( error ) {
273299 return {
274300 status : "error" ,
275301 error : error as Error ,
302+ pathPattern : assignedTask . bucketPathPattern ,
303+ sourceLocale : assignedTask . sourceLocale ,
304+ targetLocale : assignedTask . targetLocale ,
276305 } satisfies CmdRunTaskResult ;
277306 }
278307 } ) ;
0 commit comments