Compare commits

..

No commits in common. "261463bbe51d844171b674ea076cd835dee21573" and "127d3fd830f7df1f28206a7568090071c20505d2" have entirely different histories.

3 changed files with 13 additions and 16 deletions

25
main.js
View File

@ -81,29 +81,26 @@ function getBaseLogFilePath() {
return customPath || getDefaultLogFilePath(); return customPath || getDefaultLogFilePath();
} }
// Daily log: one file per day, reused across sessions on the same day // Session log: one file per app session, created lazily on first upload
let _dailyLogPath = null; let sessionLogPath = null;
let _dailyLogDate = null;
function getLogFilePath() { function getLogFilePath() {
const config = configStore.load(); const config = configStore.load();
const useDailyLog = config && config.globalSettings && config.globalSettings.sessionLog; const useSessionLog = config && config.globalSettings && config.globalSettings.sessionLog;
if (!useDailyLog) return getBaseLogFilePath(); if (!useSessionLog) return getBaseLogFilePath();
const now = new Date(); // Lazy: generate session log path on first call
const pad = (n) => String(n).padStart(2, '0'); if (!sessionLogPath) {
const today = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
// Reuse path if same day, otherwise generate new
if (_dailyLogDate !== today) {
const base = getBaseLogFilePath(); const base = getBaseLogFilePath();
const dir = path.dirname(base); const dir = path.dirname(base);
const ext = path.extname(base); const ext = path.extname(base);
const name = path.basename(base, ext); const name = path.basename(base, ext);
_dailyLogPath = path.join(dir, `${name}-${today}${ext}`); const now = new Date();
_dailyLogDate = today; const pad = (n) => String(n).padStart(2, '0');
const ts = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}_${pad(now.getHours())}-${pad(now.getMinutes())}-${pad(now.getSeconds())}`;
sessionLogPath = path.join(dir, `${name}-${ts}${ext}`);
} }
return _dailyLogPath; return sessionLogPath;
} }
function appendUploadLog(hoster, link, fileName) { function appendUploadLog(hoster, link, fileName) {

View File

@ -1,6 +1,6 @@
{ {
"name": "multi-hoster-uploader", "name": "multi-hoster-uploader",
"version": "2.0.3", "version": "2.0.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": {

View File

@ -1890,7 +1890,7 @@ function renderSettings() {
<button class="btn btn-xs btn-secondary" id="chooseLogFilePathBtn">Ordner wählen</button> <button class="btn btn-xs btn-secondary" id="chooseLogFilePathBtn">Ordner wählen</button>
</div> </div>
<div class="settings-row"> <div class="settings-row">
<label>Neues Log pro Tag</label> <label>Neues Log pro Session</label>
<input type="checkbox" class="settings-autosave" id="sessionLogInput" ${globalSettings.sessionLog ? 'checked' : ''}> <input type="checkbox" class="settings-autosave" id="sessionLogInput" ${globalSettings.sessionLog ? 'checked' : ''}>
</div> </div>
</div> </div>