Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d159ac484a | ||
|
|
f4b5fadc5f | ||
|
|
169817f707 | ||
|
|
1418c2bc17 | ||
|
|
8d33141294 | ||
|
|
35341b522a | ||
|
|
f9aa7f4168 | ||
|
|
d9199f8aaf |
@ -310,18 +310,30 @@ class UploadManager extends EventEmitter {
|
||||
this._batchResults = results;
|
||||
this._additionalPromises = []; // Track jobs added mid-batch via addJobs()
|
||||
|
||||
for (const task of tasks) {
|
||||
const fileName = path.basename(task.file);
|
||||
if (!results.has(task.file)) {
|
||||
let size = 0;
|
||||
try { size = fs.statSync(task.file).size; } catch {}
|
||||
results.set(task.file, { name: fileName, size, results: [] });
|
||||
const DEDUP_CHUNK = 200;
|
||||
for (let i = 0; i < tasks.length; i += DEDUP_CHUNK) {
|
||||
const end = Math.min(i + DEDUP_CHUNK, tasks.length);
|
||||
for (let j = i; j < end; j++) {
|
||||
const task = tasks[j];
|
||||
if (!results.has(task.file)) {
|
||||
const fileName = path.basename(task.file);
|
||||
let size = 0;
|
||||
try { size = fs.statSync(task.file).size; } catch {}
|
||||
results.set(task.file, { name: fileName, size, results: [] });
|
||||
}
|
||||
}
|
||||
if (end < tasks.length) await new Promise(setImmediate);
|
||||
}
|
||||
|
||||
this._startStatsTimer();
|
||||
|
||||
const promises = tasks.map((task) => this._runJob(task, results, signal));
|
||||
const SPAWN_CHUNK = 100;
|
||||
const promises = [];
|
||||
for (let i = 0; i < tasks.length; i += SPAWN_CHUNK) {
|
||||
const end = Math.min(i + SPAWN_CHUNK, tasks.length);
|
||||
for (let j = i; j < end; j++) promises.push(this._runJob(tasks[j], results, signal));
|
||||
if (end < tasks.length) await new Promise(setImmediate);
|
||||
}
|
||||
await Promise.allSettled(promises);
|
||||
// Wait for any jobs added mid-batch via addJobs()
|
||||
while (this._additionalPromises.length > 0) {
|
||||
|
||||
63
main.js
63
main.js
@ -216,23 +216,10 @@ function rotLog(msg, ts) {
|
||||
try {
|
||||
const iso = new Date(ts || Date.now()).toISOString();
|
||||
const line = `[${iso}] ${msg}\n`;
|
||||
// Write synchronously. Rotation events are rare (a handful per batch) so
|
||||
// the batching optimization from debugLog doesn't buy us anything, and
|
||||
// syncing guarantees the user can refresh the file and see fresh entries
|
||||
// without waiting on a flush timer.
|
||||
const candidates = [
|
||||
getRotLogPath(),
|
||||
path.join(app.getPath('desktop') || app.getPath('userData'), 'account-rotation.log'),
|
||||
path.join(app.getPath('userData'), 'account-rotation.log')
|
||||
];
|
||||
for (const target of candidates) {
|
||||
try {
|
||||
fs.mkdirSync(path.dirname(target), { recursive: true });
|
||||
fs.appendFileSync(target, line, 'utf-8');
|
||||
break;
|
||||
} catch {}
|
||||
_rotLogBuffer.push(line);
|
||||
if (!_rotLogFlushTimer) {
|
||||
_rotLogFlushTimer = setTimeout(() => { _rotLogFlushTimer = null; _flushRotLog(); }, 500);
|
||||
}
|
||||
// Mirror into the main debug log for single-file-grep convenience.
|
||||
_debugLogBuffer.push(`[${iso}] [ROT] ${msg}\n`);
|
||||
if (!_debugLogFlushTimer) {
|
||||
_debugLogFlushTimer = setTimeout(() => { _debugLogFlushTimer = null; _flushDebugLog(); }, 500);
|
||||
@ -1763,12 +1750,19 @@ ipcMain.handle('export-backup', async () => {
|
||||
const { canceled, filePath } = await dialog.showSaveDialog(mainWindow, {
|
||||
title: 'Backup exportieren',
|
||||
defaultPath: `multi-hoster-backup-${new Date().toISOString().slice(0, 10)}.mhu`,
|
||||
filters: [{ name: 'Multi-Hoster Backup', extensions: ['mhu'] }]
|
||||
filters: [
|
||||
{ name: 'Multi-Hoster Backup (verschlüsselt)', extensions: ['mhu'] },
|
||||
{ name: 'Multi-Hoster Backup (Klartext JSON)', extensions: ['json'] }
|
||||
]
|
||||
});
|
||||
if (canceled || !filePath) return { ok: false, canceled: true };
|
||||
const config = configStore.load();
|
||||
const encrypted = backupCrypto.encrypt(config);
|
||||
fs.writeFileSync(filePath, encrypted);
|
||||
if (filePath.toLowerCase().endsWith('.json')) {
|
||||
fs.writeFileSync(filePath, JSON.stringify(config, null, 2), 'utf-8');
|
||||
} else {
|
||||
const encrypted = backupCrypto.encrypt(config);
|
||||
fs.writeFileSync(filePath, encrypted);
|
||||
}
|
||||
return { ok: true, path: filePath };
|
||||
});
|
||||
|
||||
@ -1780,7 +1774,11 @@ ipcMain.handle('import-backup', async (_event, legacyPassword) => {
|
||||
} else {
|
||||
const { canceled, filePaths } = await dialog.showOpenDialog(mainWindow, {
|
||||
title: 'Backup importieren',
|
||||
filters: [{ name: 'Multi-Hoster Backup', extensions: ['mhu'] }],
|
||||
filters: [
|
||||
{ name: 'Multi-Hoster Backup', extensions: ['mhu', 'json'] },
|
||||
{ name: 'Verschlüsselt (.mhu)', extensions: ['mhu'] },
|
||||
{ name: 'Klartext (.json)', extensions: ['json'] }
|
||||
],
|
||||
properties: ['openFile']
|
||||
});
|
||||
if (canceled || !filePaths.length) return { ok: false, canceled: true };
|
||||
@ -1789,14 +1787,25 @@ ipcMain.handle('import-backup', async (_event, legacyPassword) => {
|
||||
_lastImportPath = sourcePath;
|
||||
}
|
||||
let imported;
|
||||
try {
|
||||
imported = backupCrypto.decrypt(buffer, legacyPassword);
|
||||
} catch (err) {
|
||||
if (err && err.needsPassword) {
|
||||
return { ok: false, needsPassword: true };
|
||||
const looksLikeJson = buffer.length >= 1 && (buffer[0] === 0x7B || buffer[0] === 0x20 || buffer[0] === 0x0A || buffer[0] === 0x0D || buffer[0] === 0x09 || buffer[0] === 0xEF);
|
||||
if (looksLikeJson) {
|
||||
try {
|
||||
const text = buffer.toString('utf-8').replace(/^\uFEFF/, '');
|
||||
imported = JSON.parse(text);
|
||||
} catch (err) {
|
||||
_lastImportPath = null;
|
||||
return { ok: false, error: 'Klartext-Backup ist kein gültiges JSON: ' + (err.message || err) };
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
imported = backupCrypto.decrypt(buffer, legacyPassword);
|
||||
} catch (err) {
|
||||
if (err && err.needsPassword) {
|
||||
return { ok: false, needsPassword: true, hint: 'Falls dieses Backup mit der aktuellen Version erzeugt wurde, ist die Datei vermutlich beim Transfer beschädigt worden (z. B. FTP-Text-Modus). Versuch es mit einem Klartext-JSON-Export.' };
|
||||
}
|
||||
_lastImportPath = null;
|
||||
throw err;
|
||||
}
|
||||
_lastImportPath = null;
|
||||
throw err;
|
||||
}
|
||||
_lastImportPath = null;
|
||||
// Validate imported data has required structure
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "multi-hoster-uploader",
|
||||
"version": "3.3.47",
|
||||
"version": "3.3.51",
|
||||
"description": "Upload files to doodstream, voe, vidmoly, byse simultaneously",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
@ -63,10 +63,12 @@ const queueSortState = { key: 'filename', direction: 'asc' };
|
||||
// History state
|
||||
let historyRowsData = [];
|
||||
let historySortState = { key: 'date', direction: 'desc' };
|
||||
let _historySortClicked = false;
|
||||
|
||||
// Session-specific files for the "Files" panel (resets each session)
|
||||
let sessionFilesData = [];
|
||||
const recentSortState = { key: 'date', direction: 'desc' };
|
||||
let _recentSortClicked = false;
|
||||
const selectedRecentIds = new Set();
|
||||
// Maintained incrementally — avoids O(n) filter() scans every 250ms in the status bar.
|
||||
let _sessionDoneCount = 0;
|
||||
@ -1443,7 +1445,7 @@ async function doBackupExport() {
|
||||
}
|
||||
}
|
||||
|
||||
function askLegacyBackupPassword() {
|
||||
function askLegacyBackupPassword(hint) {
|
||||
return new Promise((resolve) => {
|
||||
const overlay = document.createElement('div');
|
||||
overlay.className = 'modal-overlay';
|
||||
@ -1456,7 +1458,7 @@ function askLegacyBackupPassword() {
|
||||
const header = document.createElement('div');
|
||||
header.className = 'modal-header';
|
||||
const h3 = document.createElement('h3');
|
||||
h3.textContent = 'Passwort erforderlich';
|
||||
h3.textContent = 'Backup nicht entschlüsselbar';
|
||||
header.appendChild(h3);
|
||||
|
||||
const body = document.createElement('div');
|
||||
@ -1464,7 +1466,15 @@ function askLegacyBackupPassword() {
|
||||
const p = document.createElement('p');
|
||||
p.style.margin = '0 0 10px';
|
||||
p.style.fontSize = '13px';
|
||||
p.textContent = 'Dieses Backup wurde mit einem Passwort verschlüsselt.';
|
||||
p.textContent = 'Wenn das Backup mit der alten Passwort-Option (vor v3.0) erstellt wurde, hier eingeben.';
|
||||
if (hint) {
|
||||
const p2 = document.createElement('p');
|
||||
p2.style.margin = '0 0 10px';
|
||||
p2.style.fontSize = '12px';
|
||||
p2.style.color = 'var(--text-dim)';
|
||||
p2.textContent = hint;
|
||||
body.appendChild(p2);
|
||||
}
|
||||
const input = document.createElement('input');
|
||||
input.type = 'password';
|
||||
input.className = 'key-input';
|
||||
@ -1508,7 +1518,7 @@ async function doBackupImport(legacyPassword) {
|
||||
const result = await window.api.importBackup(pw);
|
||||
if (!result || result.canceled) return;
|
||||
if (result.needsPassword) {
|
||||
const entered = await askLegacyBackupPassword();
|
||||
const entered = await askLegacyBackupPassword(result.hint);
|
||||
if (entered) doBackupImport(entered);
|
||||
return;
|
||||
}
|
||||
@ -2522,8 +2532,10 @@ async function executeHealthCheck(hosters, _mode) {
|
||||
}
|
||||
|
||||
async function runHealthCheck(mode = 'manual', requestedHosters = null) {
|
||||
if (healthCheckRunning || (uploading && mode === 'manual')) return [];
|
||||
// Build check list: all enabled accounts with creds
|
||||
if (healthCheckRunning) {
|
||||
if (mode === 'manual') showCopyToast('Account-Check läuft bereits.');
|
||||
return [];
|
||||
}
|
||||
let hosters;
|
||||
if (Array.isArray(requestedHosters) && requestedHosters.length > 0) {
|
||||
hosters = requestedHosters;
|
||||
@ -4140,8 +4152,14 @@ function renderHistoryTable(container) {
|
||||
const th = e.target.closest('th.sortable');
|
||||
if (th && container.contains(th)) {
|
||||
const key = th.dataset.historySort;
|
||||
if (historySortState.key === key) historySortState.direction = historySortState.direction === 'asc' ? 'desc' : 'asc';
|
||||
else { historySortState.key = key; historySortState.direction = key === 'date' ? 'desc' : 'asc'; }
|
||||
const defaultDir = key === 'date' ? 'desc' : 'asc';
|
||||
if (!_historySortClicked || historySortState.key !== key) {
|
||||
_historySortClicked = true;
|
||||
historySortState.key = key;
|
||||
historySortState.direction = defaultDir;
|
||||
} else {
|
||||
historySortState.direction = historySortState.direction === 'asc' ? 'desc' : 'asc';
|
||||
}
|
||||
renderHistoryTable(container);
|
||||
return;
|
||||
}
|
||||
@ -4197,11 +4215,13 @@ function setupListeners() {
|
||||
const th = e.target.closest('th[data-recent-sort]');
|
||||
if (!th) return;
|
||||
const key = th.dataset.recentSort;
|
||||
if (recentSortState.key === key) {
|
||||
recentSortState.direction = recentSortState.direction === 'desc' ? 'asc' : 'desc';
|
||||
} else {
|
||||
const defaultDir = key === 'date' ? 'desc' : 'asc';
|
||||
if (!_recentSortClicked || recentSortState.key !== key) {
|
||||
_recentSortClicked = true;
|
||||
recentSortState.key = key;
|
||||
recentSortState.direction = key === 'date' ? 'desc' : 'asc';
|
||||
recentSortState.direction = defaultDir;
|
||||
} else {
|
||||
recentSortState.direction = recentSortState.direction === 'desc' ? 'asc' : 'desc';
|
||||
}
|
||||
renderRecentUploadsPanel();
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user