channel-worker 1.0.16 → 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 +41 -1
- package/package.json +1 -1
package/lib/command-poller.js
CHANGED
|
@@ -85,7 +85,47 @@ class CommandPoller {
|
|
|
85
85
|
} catch { /* ignore */ }
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
const
|
|
88
|
+
const baseExtPath = this.config.extension_path || '';
|
|
89
|
+
let extensionPath = baseExtPath;
|
|
90
|
+
|
|
91
|
+
// Create unique extension dir each launch → prevents Chromium bytecode cache
|
|
92
|
+
if (baseExtPath && profile_id) {
|
|
93
|
+
const fs = require('fs');
|
|
94
|
+
const path = require('path');
|
|
95
|
+
const ts = Date.now();
|
|
96
|
+
const uniqueExtPath = baseExtPath + '-' + profile_id + '-' + ts;
|
|
97
|
+
try {
|
|
98
|
+
fs.mkdirSync(uniqueExtPath, { recursive: true });
|
|
99
|
+
const files = fs.readdirSync(baseExtPath);
|
|
100
|
+
for (const f of files) {
|
|
101
|
+
const src = path.join(baseExtPath, f);
|
|
102
|
+
if (fs.statSync(src).isFile()) fs.copyFileSync(src, path.join(uniqueExtPath, f));
|
|
103
|
+
}
|
|
104
|
+
// Write profile-specific config.json
|
|
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
|
+
}
|
|
124
|
+
} catch (e) {
|
|
125
|
+
console.warn(`[commands] Unique ext dir failed: ${e.message}, using base`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
89
129
|
const result = await this.nst.launchProfile(profile_id, { proxy, extensionPath });
|
|
90
130
|
console.log(`[commands] Profile ${profile_id} launched${extensionPath ? ' (ext)' : ''}`);
|
|
91
131
|
|