feat: Fix loop uses sinceState instead of newSinceState, causing infinite loops.

This commit is contained in:
dab246
2026-02-04 09:48:50 +07:00
committed by Dat H. Pham
parent 4fea45d062
commit 41817091c1
9 changed files with 23 additions and 16 deletions
@@ -31,16 +31,16 @@ mixin BatchGetLabelProcessingMixin on HandleSetErrorMixin, SessionMixin {
}
final maxObjects = getMaxObjectsInGetMethod(session, accountId);
final totalEmails = labelIds.length;
final batchSize = max(1, min(totalEmails, maxObjects));
final totalLabels = labelIds.length;
final batchSize = max(1, min(totalLabels, maxObjects));
final List<Label> allLabels = [];
final List<Id> allNotFoundIds = [];
State? latestState;
for (int start = 0; start < totalEmails; start += batchSize) {
for (int start = 0; start < totalLabels; start += batchSize) {
int end =
(start + batchSize < totalEmails) ? start + batchSize : totalEmails;
(start + batchSize < totalLabels) ? start + batchSize : totalLabels;
final currentListIds = labelIds.sublist(start, end);
log('BatchGetLabelProcessingMixin::$debugLabel: processing batch ${start + 1} to $end');
+2 -2
View File
@@ -92,10 +92,10 @@ mixin MailAPIMixin on HandleSetErrorMixin, SessionMixin {
);
final listEmailIds = setEmailResponse?.updated?.keys.toEmailIds() ?? [];
final mapErrors = handleSetResponse([setEmailResponse]);
final batchErrors = handleSetResponse([setEmailResponse]);
updatedEmailIds.addAll(listEmailIds);
mapErrors.addAll(mapErrors);
mapErrors.addAll(batchErrors);
}
return (emailIdsSuccess: updatedEmailIds, mapErrors: mapErrors);
+1 -1
View File
@@ -22,7 +22,7 @@ mixin SessionMixin {
maxObjectsInSetMethod,
CapabilityIdentifierExtension.defaultMaxObjectsInSet,
);
log('$runtimeType::_getMaxObjectsInSetMethod:minOfMaxObjectsInSetMethod = $minOfMaxObjectsInSetMethod');
log('$runtimeType::getMaxObjectsInSetMethod:minOfMaxObjectsInSetMethod = $minOfMaxObjectsInSetMethod');
return minOfMaxObjectsInSetMethod;
}