channel-worker 1.0.17 → 1.0.18
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/lib/command-poller.js +25 -16
- package/package.json +1 -1
package/lib/command-poller.js
CHANGED
|
@@ -88,32 +88,41 @@ class CommandPoller {
|
|
|
88
88
|
const baseExtPath = this.config.extension_path || '';
|
|
89
89
|
let extensionPath = baseExtPath;
|
|
90
90
|
|
|
91
|
-
// Create
|
|
91
|
+
// Create unique extension dir each launch → prevents Chromium bytecode cache
|
|
92
92
|
if (baseExtPath && profile_id) {
|
|
93
93
|
const fs = require('fs');
|
|
94
94
|
const path = require('path');
|
|
95
|
-
const
|
|
95
|
+
const ts = Date.now();
|
|
96
|
+
const uniqueExtPath = baseExtPath + '-' + profile_id + '-' + ts;
|
|
96
97
|
try {
|
|
97
|
-
|
|
98
|
-
if (!fs.existsSync(profileExtPath)) fs.mkdirSync(profileExtPath, { recursive: true });
|
|
98
|
+
fs.mkdirSync(uniqueExtPath, { recursive: true });
|
|
99
99
|
const files = fs.readdirSync(baseExtPath);
|
|
100
100
|
for (const f of files) {
|
|
101
101
|
const src = path.join(baseExtPath, f);
|
|
102
|
-
|
|
103
|
-
if (fs.statSync(src).isFile()) {
|
|
104
|
-
// Copy if newer
|
|
105
|
-
const srcMtime = fs.statSync(src).mtimeMs;
|
|
106
|
-
const dstMtime = fs.existsSync(dst) ? fs.statSync(dst).mtimeMs : 0;
|
|
107
|
-
if (srcMtime > dstMtime) fs.copyFileSync(src, dst);
|
|
108
|
-
}
|
|
102
|
+
if (fs.statSync(src).isFile()) fs.copyFileSync(src, path.join(uniqueExtPath, f));
|
|
109
103
|
}
|
|
110
104
|
// Write profile-specific config.json
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
105
|
+
fs.writeFileSync(path.join(uniqueExtPath, 'config.json'), JSON.stringify({
|
|
106
|
+
channelManagerApi: 'https://api.channel.tunasm.art',
|
|
107
|
+
profileId: profile_id,
|
|
108
|
+
}));
|
|
109
|
+
extensionPath = uniqueExtPath;
|
|
110
|
+
console.log(`[commands] Extension dir: ${uniqueExtPath}`);
|
|
111
|
+
|
|
112
|
+
// Cleanup old dirs (keep last 3)
|
|
113
|
+
const parent = path.dirname(baseExtPath);
|
|
114
|
+
const baseName = path.basename(baseExtPath);
|
|
115
|
+
const oldDirs = fs.readdirSync(parent)
|
|
116
|
+
.filter(d => d.startsWith(baseName + '-') && d !== path.basename(uniqueExtPath))
|
|
117
|
+
.map(d => path.join(parent, d))
|
|
118
|
+
.filter(d => fs.statSync(d).isDirectory())
|
|
119
|
+
.sort()
|
|
120
|
+
.slice(0, -3);
|
|
121
|
+
for (const d of oldDirs) {
|
|
122
|
+
try { fs.rmSync(d, { recursive: true }); } catch {}
|
|
123
|
+
}
|
|
115
124
|
} catch (e) {
|
|
116
|
-
console.warn(`[commands]
|
|
125
|
+
console.warn(`[commands] Unique ext dir failed: ${e.message}, using base`);
|
|
117
126
|
}
|
|
118
127
|
}
|
|
119
128
|
|