feat: track cache changes with sequence numbers and tombstones

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-10-07 21:21:14 -04:00
parent c20dde6633
commit eea9b5630a
10 changed files with 511 additions and 46 deletions
+7 -2
View File
@@ -13,6 +13,7 @@ use KTXC\Context\TenantContext;
use KTXM\ProviderImap\Providers\Provider;
use KTXM\ProviderImap\Providers\Service;
use KTXM\ProviderImap\Service\Cache\HarmonizationService;
use KTXM\ProviderImap\Service\Cache\MessageDeltaService;
use KTXM\ProviderImap\Stores\MailboxStore;
use KTXM\ProviderImap\Stores\MessageStore;
use Symfony\Component\Console\Attribute\AsCommand;
@@ -141,9 +142,10 @@ class HarmonizeCommand extends Command
foreach ($messages as $name => $outcome) {
if (is_string($outcome)) {
$failed++;
$rows[] = [$name, '<error>failed</error>', '', '', '', '', $outcome];
$rows[] = [$name, '<error>failed</error>', '', '', '', '', '', $outcome];
continue;
}
$state = $this->mailboxStore->state($serviceId, (string) $name);
$rows[] = [
$name,
$outcome['status'],
@@ -151,10 +153,13 @@ class HarmonizeCommand extends Command
$outcome['updated'],
$outcome['removed'],
$outcome['complete'] ? 'yes' : 'no',
$state['uidValidity'] !== null
? MessageDeltaService::signature((int) $state['uidValidity'], (int) $state['changeSeq'])
: '',
$outcome['reset'] ? 'UIDVALIDITY changed, cache reset' : '',
];
}
$io->table(['Mailbox', 'Status', 'Added', 'Updated', 'Removed', 'Complete', 'Note'], $rows);
$io->table(['Mailbox', 'Status', 'Added', 'Updated', 'Removed', 'Complete', 'Signature', 'Note'], $rows);
$io->writeln(sprintf(
'Cache: <info>storage/%s/provider_imap/%s</info>, MongoDB <info>provider_imap_mail_mailboxes</info> / <info>provider_imap_mail_messages</info>',