Compare commits

..

2 Commits

Author SHA1 Message Date
Administrator
b80ca7238d release: v2.8.2 2026-04-19 11:47:17 +02:00
Administrator
415162e058 fix(log): fall back to user's Desktop before AppData, keep daily-log naming
If the configured log path (or the default exe-adjacent path) isn't
writable, we now try the current user's Desktop first — that's where
users actually look — and only fall back to AppData if Desktop is
also unavailable. The daily-log filename suffix is preserved on the
fallback file so the format stays consistent.
2026-04-19 11:46:50 +02:00
2 changed files with 42 additions and 4 deletions

44
main.js
View File

@ -113,6 +113,25 @@ function getLogFilePath() {
return _dailyLogPath;
}
function buildFallbackLogName(dir) {
// Match the daily-log naming when enabled, so fallback files stay consistent.
const config = configStore.load();
const useDailyLog = config && config.globalSettings && config.globalSettings.sessionLog;
if (!useDailyLog) return path.join(dir, 'fileuploader.log');
const now = new Date();
const pad = (n) => String(n).padStart(2, '0');
const today = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
return path.join(dir, `fileuploader-${today}.log`);
}
function getSafeDesktopDir() {
try {
const desktop = app.getPath('desktop');
if (desktop && fs.existsSync(desktop)) return desktop;
} catch {}
return null;
}
let _uploadLogFallbackWarned = false;
function appendUploadLog(hoster, link, fileName) {
const now = new Date();
@ -129,11 +148,30 @@ function appendUploadLog(hoster, link, fileName) {
tryWrite(getLogFilePath());
return;
} catch (err) {
debugLog(`appendUploadLog primary failed (${err.message}); using fallback`);
debugLog(`appendUploadLog primary failed (${err.message}); trying desktop fallback`);
}
// Fallback 1: current user's Desktop (visible, easy to find).
const desktop = getSafeDesktopDir();
if (desktop) {
try {
const fallbackPath = buildFallbackLogName(desktop);
tryWrite(fallbackPath);
if (!_uploadLogFallbackWarned) {
_uploadLogFallbackWarned = true;
if (mainWindow && !mainWindow.isDestroyed()) {
mainWindow.webContents.send('upload-log-fallback', { fallbackPath });
}
}
return;
} catch (err) {
debugLog(`appendUploadLog desktop fallback failed (${err.message}); trying userData`);
}
}
// Fallback 2: userData (always writable by the current user).
try {
const fallbackPath = path.join(app.getPath('userData'), 'fileuploader-fallback.log');
const fallbackPath = buildFallbackLogName(app.getPath('userData'));
tryWrite(fallbackPath);
if (!_uploadLogFallbackWarned) {
_uploadLogFallbackWarned = true;
@ -142,7 +180,7 @@ function appendUploadLog(hoster, link, fileName) {
}
}
} catch (err) {
debugLog(`appendUploadLog fallback also failed: ${err.message}`);
debugLog(`appendUploadLog all fallbacks failed: ${err.message}`);
}
}

View File

@ -1,6 +1,6 @@
{
"name": "multi-hoster-uploader",
"version": "2.8.1",
"version": "2.8.2",
"description": "Upload files to doodstream, voe, vidmoly, byse simultaneously",
"main": "main.js",
"scripts": {