@bobfrankston/mailx-imap 0.1.15 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +26 -4
- package/package.json +13 -13
package/index.js
CHANGED
|
@@ -956,9 +956,22 @@ export class ImapManager extends EventEmitter {
|
|
|
956
956
|
this.emit("folderCountsChanged", accountId, {});
|
|
957
957
|
}
|
|
958
958
|
};
|
|
959
|
-
|
|
960
|
-
//
|
|
961
|
-
|
|
959
|
+
// Fast first-sync: fetch the most recent N messages by sequence
|
|
960
|
+
// number rather than running SEARCH SINCE 30-days-ago. SEARCH
|
|
961
|
+
// SINCE walks INTERNALDATE on every message in the mailbox,
|
|
962
|
+
// which takes minutes on a cold Dovecot mailbox of any size;
|
|
963
|
+
// sequence FETCH is O(1) per message because the server reads
|
|
964
|
+
// message slots directly. The 30-day window is recovered by
|
|
965
|
+
// the existing backfill logic in subsequent sync cycles.
|
|
966
|
+
const FIRST_SYNC_RECENT_COUNT = 200;
|
|
967
|
+
if (typeof client.fetchLatestN === "function") {
|
|
968
|
+
messages = await client.fetchLatestN(folder.path, FIRST_SYNC_RECENT_COUNT, { source: false }, onChunk);
|
|
969
|
+
}
|
|
970
|
+
else {
|
|
971
|
+
// Older iflow-direct without fetchLatestN — fall back to date.
|
|
972
|
+
const tomorrow = new Date(Date.now() + 86400000);
|
|
973
|
+
messages = await client.fetchMessageByDate(folder.path, startDate, tomorrow, { source: false }, onChunk);
|
|
974
|
+
}
|
|
962
975
|
if (totalStored > 0) {
|
|
963
976
|
console.log(` ${folder.path}: ${totalStored} messages (streamed)`);
|
|
964
977
|
this.db.recalcFolderCounts(folderId);
|
|
@@ -1247,7 +1260,16 @@ export class ImapManager extends EventEmitter {
|
|
|
1247
1260
|
return pa - pb;
|
|
1248
1261
|
});
|
|
1249
1262
|
const CONCURRENCY = 2;
|
|
1250
|
-
|
|
1263
|
+
// First-sync of a fresh account on a cold Dovecot is dominated by
|
|
1264
|
+
// `UID SEARCH SINCE 30-days-ago`, which can take 5+ minutes on a
|
|
1265
|
+
// large mailbox while the server walks INTERNALDATE on every
|
|
1266
|
+
// message. The previous 60s cap killed every non-INBOX folder
|
|
1267
|
+
// before SEARCH returned, leaving "all subfolders empty" — even
|
|
1268
|
+
// though the connection itself was healthy. After first sync,
|
|
1269
|
+
// incremental fetches (UID > highestUid) are fast, so the long
|
|
1270
|
+
// timeout only hurts on the very first sync of a busy account.
|
|
1271
|
+
// 6 minutes matches Dovecot's 300s inactivity timeout + buffer.
|
|
1272
|
+
const PER_FOLDER_TIMEOUT_MS = 360_000;
|
|
1251
1273
|
const total = remaining.length;
|
|
1252
1274
|
let done = 0;
|
|
1253
1275
|
let idx = 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bobfrankston/mailx-imap",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
},
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@bobfrankston/mailx-types": "^0.1.
|
|
13
|
-
"@bobfrankston/mailx-settings": "^0.1.
|
|
14
|
-
"@bobfrankston/mailx-store": "^0.1.
|
|
15
|
-
"@bobfrankston/iflow-direct": "^0.1.
|
|
12
|
+
"@bobfrankston/mailx-types": "^0.1.6",
|
|
13
|
+
"@bobfrankston/mailx-settings": "^0.1.7",
|
|
14
|
+
"@bobfrankston/mailx-store": "^0.1.7",
|
|
15
|
+
"@bobfrankston/iflow-direct": "^0.1.28",
|
|
16
16
|
"@bobfrankston/tcp-transport": "^0.1.5",
|
|
17
17
|
"@bobfrankston/smtp-direct": "^0.1.5",
|
|
18
|
-
"@bobfrankston/mailx-sync": "^0.1.
|
|
19
|
-
"@bobfrankston/oauthsupport": "^1.0.
|
|
18
|
+
"@bobfrankston/mailx-sync": "^0.1.12",
|
|
19
|
+
"@bobfrankston/oauthsupport": "^1.0.26"
|
|
20
20
|
},
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
},
|
|
38
38
|
".transformedSnapshot": {
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@bobfrankston/mailx-types": "^0.1.
|
|
41
|
-
"@bobfrankston/mailx-settings": "^0.1.
|
|
42
|
-
"@bobfrankston/mailx-store": "^0.1.
|
|
43
|
-
"@bobfrankston/iflow-direct": "^0.1.
|
|
40
|
+
"@bobfrankston/mailx-types": "^0.1.6",
|
|
41
|
+
"@bobfrankston/mailx-settings": "^0.1.7",
|
|
42
|
+
"@bobfrankston/mailx-store": "^0.1.7",
|
|
43
|
+
"@bobfrankston/iflow-direct": "^0.1.28",
|
|
44
44
|
"@bobfrankston/tcp-transport": "^0.1.5",
|
|
45
45
|
"@bobfrankston/smtp-direct": "^0.1.5",
|
|
46
|
-
"@bobfrankston/mailx-sync": "^0.1.
|
|
47
|
-
"@bobfrankston/oauthsupport": "^1.0.
|
|
46
|
+
"@bobfrankston/mailx-sync": "^0.1.12",
|
|
47
|
+
"@bobfrankston/oauthsupport": "^1.0.26"
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|