ux(log): default fileuploader.log path is now the user's Desktop

In packaged builds path.dirname(process.execPath) resolves to
%LOCALAPPDATA%\Programs\Multi-Hoster-Upload — a hidden install
directory the user never visits and that NSIS may prune on
uninstall. Existing files written there were effectively invisible.

Change the unconfigured-default to app.getPath('desktop') instead.
If Desktop isn't available (rare), fall back to userData (Roaming),
and finally to the exe dir as a last resort. Dev mode (isPackaged
false) is unchanged — keeps the project dir for inspection.

Custom log paths set via the Settings UI override this and continue
to work as before. Existing users with old logs in the install dir
will just see a new fileuploader.log on the Desktop going forward;
the old file stays where it is (not auto-migrated).

137/137 tests still green.
This commit is contained in:
Administrator 2026-05-23 01:10:10 +02:00
parent c741503665
commit 2208632154

20
main.js
View File

@ -212,10 +212,22 @@ function normalizeApiError(payload, fallback) {
} }
function getDefaultLogFilePath() { function getDefaultLogFilePath() {
const baseDir = app.isPackaged // In packaged builds the exe dir is %LOCALAPPDATA%\Programs\Multi-Hoster-Upload
? path.dirname(process.execPath) // — a hidden, install-managed location that NSIS may even prune on
: path.join(__dirname); // uninstall. Default to the user's Desktop so the file is actually
return path.join(baseDir, 'fileuploader.log'); // findable; fall back to userData if Desktop isn't available, and
// finally to the project dir in dev mode.
if (app.isPackaged) {
try {
const desktop = app.getPath('desktop');
if (desktop) return path.join(desktop, 'fileuploader.log');
} catch {}
try {
return path.join(app.getPath('userData'), 'fileuploader.log');
} catch {}
return path.join(path.dirname(process.execPath), 'fileuploader.log');
}
return path.join(__dirname, 'fileuploader.log');
} }
function getBaseLogFilePath() { function getBaseLogFilePath() {