Compare commits
2 Commits
fdac28040d
...
b80ca7238d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b80ca7238d | ||
|
|
415162e058 |
44
main.js
44
main.js
@ -113,6 +113,25 @@ function getLogFilePath() {
|
|||||||
return _dailyLogPath;
|
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;
|
let _uploadLogFallbackWarned = false;
|
||||||
function appendUploadLog(hoster, link, fileName) {
|
function appendUploadLog(hoster, link, fileName) {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
@ -129,11 +148,30 @@ function appendUploadLog(hoster, link, fileName) {
|
|||||||
tryWrite(getLogFilePath());
|
tryWrite(getLogFilePath());
|
||||||
return;
|
return;
|
||||||
} catch (err) {
|
} 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 {
|
try {
|
||||||
const fallbackPath = path.join(app.getPath('userData'), 'fileuploader-fallback.log');
|
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 = buildFallbackLogName(app.getPath('userData'));
|
||||||
tryWrite(fallbackPath);
|
tryWrite(fallbackPath);
|
||||||
if (!_uploadLogFallbackWarned) {
|
if (!_uploadLogFallbackWarned) {
|
||||||
_uploadLogFallbackWarned = true;
|
_uploadLogFallbackWarned = true;
|
||||||
@ -142,7 +180,7 @@ function appendUploadLog(hoster, link, fileName) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
debugLog(`appendUploadLog fallback also failed: ${err.message}`);
|
debugLog(`appendUploadLog all fallbacks failed: ${err.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "multi-hoster-uploader",
|
"name": "multi-hoster-uploader",
|
||||||
"version": "2.8.1",
|
"version": "2.8.2",
|
||||||
"description": "Upload files to doodstream, voe, vidmoly, byse simultaneously",
|
"description": "Upload files to doodstream, voe, vidmoly, byse simultaneously",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user