replace gmail resync with Gmail REST API, remove mbsync dependency
First sync still uses IMAP with app password. Subsequent syncs use Gmail API history.list + messages.get with OAuth for faster, more reliable incremental sync. Dispatch gmail-sync handler for gmail accounts instead of generic email-sync. Show sync button for synced accounts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
import { join } from 'node:path';
|
||||
import { unlinkSync } from 'node:fs';
|
||||
import { openEmailDb } from '../src/servers/api/email/email-db';
|
||||
import { importMaildir } from '../src/servers/queue/handlers/gmail-sync';
|
||||
|
||||
const DATA_PATH = process.env.DATA_PATH ?? join(process.cwd(), 'data');
|
||||
const email = process.argv[2];
|
||||
|
||||
if (!email) {
|
||||
console.error('Usage: bun scripts/reimport-gmail.ts <email>');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const maildirPath = join(DATA_PATH, email, 'Gmail', 'Maildir');
|
||||
const dbPath = join(DATA_PATH, email, 'emails.db');
|
||||
|
||||
// Delete existing DB for a fresh import
|
||||
try {
|
||||
unlinkSync(dbPath);
|
||||
console.log(`Deleted ${dbPath}`);
|
||||
} catch {
|
||||
console.log('No existing DB to delete');
|
||||
}
|
||||
|
||||
const db = openEmailDb(email);
|
||||
|
||||
console.log(`Importing from ${maildirPath}...`);
|
||||
const result = await importMaildir({ maildirPath, emailAccount: email, db, onProgress: (saved, skipped) => {
|
||||
process.stdout.write(`\r saved ${saved}, skipped ${skipped}`);
|
||||
}});
|
||||
|
||||
console.log(`\nDone: saved ${result.saved}, skipped ${result.skipped}, errors ${result.errors}`);
|
||||
db.close();
|
||||
Reference in New Issue
Block a user