Skip to content

Commit 935bfc1

Browse files
committed
v1.3.2
1 parent bed7ef3 commit 935bfc1

File tree

5 files changed

+27
-45
lines changed

5 files changed

+27
-45
lines changed

electron/main.js

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ function openLocal() {
7676

7777
function buildTray() {
7878
// Tray-only app: no windows, just menu actions.
79-
const iconPath = path.join(getAppRoot(), 'public', 'assets', 'favicon-16x16.png');
79+
const iconPath = process.platform === 'win32'
80+
? path.join(getAppRoot(), 'public', 'assets', 'favicon.ico')
81+
: path.join(getAppRoot(), 'public', 'assets', 'favicon-16x16.png');
8082
const baseIcon = nativeImage.createFromPath(iconPath);
8183
const targetSize = process.platform === 'darwin' ? 16 : 24;
8284
const trayIcon = baseIcon.isEmpty()
@@ -145,7 +147,7 @@ function checkForUpdatesWithFeedback() {
145147
showUpdateMessage({
146148
type: 'info',
147149
message: 'Update available',
148-
detail: 'Update available. Downloading...'
150+
detail: 'Downloading update...'
149151
});
150152
finish();
151153
};
@@ -198,30 +200,10 @@ function checkForUpdatesInBackground() {
198200
});
199201
}
200202

201-
async function getCachedUpdateFileName(cacheDir) {
202-
const infoPath = path.join(cacheDir, 'update-info.json');
203-
try {
204-
const raw = await fs.promises.readFile(infoPath, 'utf8');
205-
const info = JSON.parse(raw);
206-
if (info && typeof info.fileName === 'string' && info.fileName) {
207-
return info.fileName;
208-
}
209-
} catch (error) {
210-
if (!(error && error.code === 'ENOENT')) {
211-
console.error('[Updater] Cache cleanup failed:', error && error.message ? error.message : String(error));
212-
}
213-
}
214-
return null;
215-
}
216-
217-
async function cleanupOldUpdateCaches({ downloadedFile, pendingDir }) {
218-
const cacheDir = pendingDir || (downloadedFile ? path.dirname(downloadedFile) : null);
219-
if (!cacheDir) return;
220-
221-
const updateFileName = downloadedFile
222-
? path.basename(downloadedFile)
223-
: await getCachedUpdateFileName(cacheDir);
224-
if (!updateFileName) return;
203+
async function cleanupOldUpdateCaches(downloadedFile) {
204+
if (!downloadedFile) return;
205+
const cacheDir = path.dirname(downloadedFile);
206+
const updateFileName = path.basename(downloadedFile);
225207
const keepNames = new Set();
226208
keepNames.add('update-info.json');
227209
keepNames.add('current.blockmap');
@@ -237,9 +219,8 @@ async function cleanupOldUpdateCaches({ downloadedFile, pendingDir }) {
237219
return;
238220
}
239221

240-
const shouldKeep = keepNames.size > 0;
241222
await Promise.all(entries.map(async (entry) => {
242-
if (shouldKeep && (keepNames.has(entry.name) || entry.name.startsWith('package-'))) return;
223+
if (keepNames.has(entry.name) || entry.name.startsWith('package-')) return;
243224
const entryPath = path.join(cacheDir, entry.name);
244225
try {
245226
await fs.promises.rm(entryPath, { recursive: true, force: true });
@@ -249,18 +230,6 @@ async function cleanupOldUpdateCaches({ downloadedFile, pendingDir }) {
249230
}));
250231
}
251232

252-
async function cleanupUpdateCachesOnLaunch() {
253-
if (!app.isPackaged) return;
254-
if (typeof autoUpdater.getOrCreateDownloadHelper !== 'function') return;
255-
try {
256-
const helper = await autoUpdater.getOrCreateDownloadHelper();
257-
if (!helper || !helper.cacheDirForPendingUpdate) return;
258-
await cleanupOldUpdateCaches({ pendingDir: helper.cacheDirForPendingUpdate });
259-
} catch (error) {
260-
console.error('[Updater] Cache cleanup failed:', error && error.message ? error.message : String(error));
261-
}
262-
}
263-
264233
async function showUpdateReadyDialog() {
265234
if (!updateReadyInfo) return;
266235
const result = await dialog.showMessageBox({
@@ -280,11 +249,10 @@ function setupAutoUpdater() {
280249
// Updates only work for packaged builds with GitHub Releases.
281250
if (!app.isPackaged) return;
282251
autoUpdater.autoDownload = true;
283-
cleanupUpdateCachesOnLaunch();
284252
autoUpdater.on('update-downloaded', async (info) => {
285253
updateReadyInfo = info || { version: 'unknown' };
286254
updateTrayMenu();
287-
await cleanupOldUpdateCaches({ downloadedFile: info && info.downloadedFile });
255+
await cleanupOldUpdateCaches(info && info.downloadedFile);
288256
});
289257
autoUpdater.on('error', (error) => {
290258
const detail = error && error.message ? error.message : String(error);

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "youtube2txt",
3-
"version": "1.3.1",
3+
"version": "1.3.2",
44
"description": "Local server for fetching YouTube transcripts",
55
"author": "SPACESODA",
66
"main": "server.js",

scripts/run-electron.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ const env = { ...process.env };
1313
delete env.ELECTRON_RUN_AS_NODE;
1414

1515
const child = spawn(electronPath, args, { stdio: 'inherit', env });
16+
child.on('error', (error) => {
17+
console.error('Failed to launch Electron:', error.message || error);
18+
process.exit(1);
19+
});
20+
['SIGINT', 'SIGTERM'].forEach((signal) => {
21+
process.on(signal, () => {
22+
if (!child.killed) {
23+
child.kill(signal);
24+
}
25+
});
26+
});
1627
child.on('close', (code, signal) => {
1728
if (code === null) {
1829
console.error(electronPath, 'exited with signal', signal);

server.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ function applyRuntimeConfig(options = {}) {
2222
const dataDir = options.dataDir
2323
? path.resolve(options.dataDir)
2424
: (process.env.YT2TXT_DATA_DIR ? path.resolve(process.env.YT2TXT_DATA_DIR) : appRoot);
25+
if (DATA_DIR !== dataDir) {
26+
ytdlpSetupPromise = null;
27+
}
2528
DATA_DIR = dataDir;
2629
PUBLIC_DIR = options.publicDir ? path.resolve(options.publicDir) : path.join(appRoot, 'public');
2730
BIN_DIR = path.join(DATA_DIR, 'bin');

0 commit comments

Comments
 (0)