@bobfrankston/mailx-imap 0.1.112 → 0.1.113

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 (2) hide show
  1. package/index.js +17 -3
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -5728,10 +5728,11 @@ export class ImapManager extends EventEmitter {
5728
5728
  // Compare after the debounce window and only emit on a real change.
5729
5729
  const normalize = (s) => s.replace(/^\uFEFF/, "").replace(/\r\n/g, "\n").replace(/[ \t\r\n]+$/, "");
5730
5730
  const lastContent = new Map();
5731
- for (const filename of files) {
5731
+ const watched = new Set();
5732
+ const watchOne = (filename) => {
5732
5733
  const full = path.join(configDir, filename);
5733
5734
  if (!fs.existsSync(full))
5734
- continue;
5735
+ return false;
5735
5736
  try {
5736
5737
  lastContent.set(filename, normalize(fs.readFileSync(full, "utf-8")));
5737
5738
  }
@@ -5773,11 +5774,16 @@ export class ImapManager extends EventEmitter {
5773
5774
  }, 500));
5774
5775
  });
5775
5776
  this.configWatchers.push(watcher);
5777
+ watched.add(filename);
5778
+ return true;
5776
5779
  }
5777
5780
  catch (e) {
5778
5781
  console.error(` [watch] Failed to watch ${filename}: ${e.message}`);
5782
+ return false;
5779
5783
  }
5780
- }
5784
+ };
5785
+ for (const filename of files)
5786
+ watchOne(filename);
5781
5787
  // GDrive has no push/watch for arbitrary Drive files, so edits on
5782
5788
  // another device (or via Drive web) never fire fs.watch locally.
5783
5789
  // Poll the cloud copies of the replicated-to-cloud config files
@@ -5828,6 +5834,14 @@ export class ImapManager extends EventEmitter {
5828
5834
  }
5829
5835
  fs.writeFileSync(localPath, cloudContent);
5830
5836
  console.log(` [cloud-poll] ${filename} updated from cloud copy`);
5837
+ // A file that didn't exist at startup never got an
5838
+ // fs.watch (watchOne skipped it), so the write above
5839
+ // fires nothing and the cloud edit would be applied to
5840
+ // disk but never loaded. Register the watcher now and
5841
+ // emit configChanged directly for this first change.
5842
+ if (!watched.has(filename) && watchOne(filename)) {
5843
+ this.emit("configChanged", filename);
5844
+ }
5831
5845
  }
5832
5846
  catch (e) {
5833
5847
  console.log(` [cloud-poll] ${filename} check skipped: ${e?.message || e}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx-imap",
3
- "version": "0.1.112",
3
+ "version": "0.1.113",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "@bobfrankston/mailx-types": "^0.1.22",
13
13
  "@bobfrankston/mailx-settings": "^0.1.33",
14
- "@bobfrankston/mailx-store": "^0.1.57",
14
+ "@bobfrankston/mailx-store": "^0.1.58",
15
15
  "@bobfrankston/iflow-direct": "^0.1.56",
16
16
  "@bobfrankston/tcp-transport": "^0.1.7",
17
17
  "@bobfrankston/smtp-direct": "^0.1.9",
@@ -39,7 +39,7 @@
39
39
  "dependencies": {
40
40
  "@bobfrankston/mailx-types": "^0.1.22",
41
41
  "@bobfrankston/mailx-settings": "^0.1.33",
42
- "@bobfrankston/mailx-store": "^0.1.57",
42
+ "@bobfrankston/mailx-store": "^0.1.58",
43
43
  "@bobfrankston/iflow-direct": "^0.1.56",
44
44
  "@bobfrankston/tcp-transport": "^0.1.7",
45
45
  "@bobfrankston/smtp-direct": "^0.1.9",