@bobfrankston/mailx-store 0.1.42 → 0.1.43

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.
Files changed (3) hide show
  1. package/db.d.ts +1 -1
  2. package/db.js +12 -2
  3. package/package.json +3 -3
package/db.d.ts CHANGED
@@ -371,7 +371,7 @@ export declare class MailxDB {
371
371
  * reply arrives. Idempotent — UPDATE on an already-1 row is a no-op. */
372
372
  markRepliedByMessageId(accountId: string, messageId: string): boolean;
373
373
  /** Get messages without cached bodies (for background prefetch) */
374
- getMessagesWithoutBody(accountId: string, limit?: number): {
374
+ getMessagesWithoutBody(accountId: string, limit?: number, excludeFolderIds?: number[]): {
375
375
  uid: number;
376
376
  folderId: number;
377
377
  }[];
package/db.js CHANGED
@@ -1998,14 +1998,24 @@ export class MailxDB {
1998
1998
  return r.changes > 0;
1999
1999
  }
2000
2000
  /** Get messages without cached bodies (for background prefetch) */
2001
- getMessagesWithoutBody(accountId, limit = 50) {
2001
+ getMessagesWithoutBody(accountId, limit = 50, excludeFolderIds = []) {
2002
2002
  // Prefetch order: smallest first, NULLs last, recent within tiebreak.
2003
2003
  // Reasoning: on slow / metered Android networks, the user feels the
2004
2004
  // cache "fill up" much faster when the queue is dominated by short
2005
2005
  // notification mails (a handful of KB each) instead of a single
2006
2006
  // multi-megabyte attachment that monopolizes bandwidth for minutes.
2007
2007
  // Size 0 / NULL fall to the end so they don't masquerade as small.
2008
- return this.db.prepare("SELECT uid, folder_id as folderId FROM messages WHERE account_id = ? AND (body_path IS NULL OR body_path = '') ORDER BY (size IS NULL OR size = 0), size ASC, date DESC LIMIT ?").all(accountId, limit);
2008
+ //
2009
+ // excludeFolderIds: folders the caller has put in error-cooldown. We
2010
+ // exclude them HERE (at the query) rather than after slicing, because a
2011
+ // single bloated/failing folder (e.g. a server-side Outbox stuffed with
2012
+ // hundreds of stuck messages) would otherwise fill the entire size-asc
2013
+ // result and starve every healthy folder of its prefetch turn — the
2014
+ // "so much unfetched, nothing draining" symptom (Bob 2026-06-01).
2015
+ const exclusion = excludeFolderIds.length
2016
+ ? ` AND folder_id NOT IN (${excludeFolderIds.map(() => "?").join(",")})`
2017
+ : "";
2018
+ return this.db.prepare(`SELECT uid, folder_id as folderId FROM messages WHERE account_id = ? AND (body_path IS NULL OR body_path = '')${exclusion} ORDER BY (size IS NULL OR size = 0), size ASC, date DESC LIMIT ?`).all(accountId, ...excludeFolderIds, limit);
2009
2019
  }
2010
2020
  /** Highest server UID we've seen in this folder. After the
2011
2021
  * message_folders refactor, this reads from the membership table
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx-store",
3
- "version": "0.1.42",
3
+ "version": "0.1.43",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -10,7 +10,7 @@
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
12
  "@bobfrankston/mailx-types": "^0.1.18",
13
- "@bobfrankston/mailx-settings": "^0.1.25",
13
+ "@bobfrankston/mailx-settings": "^0.1.26",
14
14
  "@bobfrankston/mailx-bus": "^0.1.2",
15
15
  "mailparser": "^3.7.2"
16
16
  },
@@ -30,7 +30,7 @@
30
30
  ".transformedSnapshot": {
31
31
  "dependencies": {
32
32
  "@bobfrankston/mailx-types": "^0.1.18",
33
- "@bobfrankston/mailx-settings": "^0.1.25",
33
+ "@bobfrankston/mailx-settings": "^0.1.26",
34
34
  "@bobfrankston/mailx-bus": "^0.1.2",
35
35
  "mailparser": "^3.7.2"
36
36
  }