Compare commits

..

No commits in common. "39ccb904ef7fccc528a98bfb49898d50b857ebc7" and "153ea2b193d0ae8c17661c594bff3a9791315c58" have entirely different histories.

9 changed files with 12 additions and 25 deletions

View File

@ -10,7 +10,7 @@ const UPLOAD_TIMEOUT = 1800000; // 30 min
function _debugLog(msg) { function _debugLog(msg) {
try { try {
const ts = new Date().toISOString(); const ts = new Date().toISOString();
fs.appendFileSync(path.join(__dirname, '..', 'doodstream-debug.log'), `[${ts}] ${msg}\n`); fs.appendFileSync(path.join(process.cwd(), 'doodstream-debug.log'), `[${ts}] ${msg}\n`);
} catch {} } catch {}
} }

View File

@ -254,7 +254,6 @@ function createUploadBody(filePath, formFields, onProgress, throttle, signal) {
yield preambleBuf; yield preambleBuf;
const fileStream = fs.createReadStream(filePath, { highWaterMark: CHUNK_SIZE }); const fileStream = fs.createReadStream(filePath, { highWaterMark: CHUNK_SIZE });
for await (const chunk of fileStream) { for await (const chunk of fileStream) {
if (signal && signal.aborted) throw new Error('Aborted');
if (throttle) await throttle.consume(chunk.length, signal); if (throttle) await throttle.consume(chunk.length, signal);
bytesRead += chunk.length; bytesRead += chunk.length;
yield chunk; yield chunk;

View File

@ -21,7 +21,6 @@ class Throttle {
bytes -= available; bytes -= available;
} }
if (bytes > 0) { if (bytes > 0) {
if (signal && signal.aborted) return;
// Wait 50ms for tokens to refill // Wait 50ms for tokens to refill
await new Promise((r) => setTimeout(r, 50)); await new Promise((r) => setTimeout(r, 50));
} }

View File

@ -56,8 +56,7 @@ function findLatestYml(assets) {
async function fetchJson(url, signal) { async function fetchJson(url, signal) {
const controller = new AbortController(); const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), CHECK_TIMEOUT); const timeout = setTimeout(() => controller.abort(), CHECK_TIMEOUT);
const onAbort = () => controller.abort(); if (signal) signal.addEventListener('abort', () => controller.abort());
if (signal) signal.addEventListener('abort', onAbort);
try { try {
const res = await fetch(url, { const res = await fetch(url, {
@ -68,7 +67,6 @@ async function fetchJson(url, signal) {
return await res.json(); return await res.json();
} finally { } finally {
clearTimeout(timeout); clearTimeout(timeout);
if (signal) signal.removeEventListener('abort', onAbort);
} }
} }

View File

@ -48,20 +48,13 @@ class UploadManager extends EventEmitter {
sem.updateLimit(settings.parallelCount); sem.updateLimit(settings.parallelCount);
} }
// Update global throttle if speed limit changed // Update global throttle if speed limit changed
if (this.globalThrottle) {
const newKbs = (this.globalSettings.globalMaxSpeedKbs || 0); const newKbs = (this.globalSettings.globalMaxSpeedKbs || 0);
if (newKbs > 0) { if (newKbs > 0) {
if (this.globalThrottle) {
this.globalThrottle.updateRate(newKbs * 1024); this.globalThrottle.updateRate(newKbs * 1024);
} else {
this.globalThrottle = new Throttle(newKbs * 1024);
}
} else { } else {
this.globalThrottle = null; this.globalThrottle = null;
} }
// Update global semaphore live
const globalLimit = this._getGlobalParallelLimit();
if (globalLimit > 0 && this.globalSemaphore) {
this.globalSemaphore.updateLimit(globalLimit);
} }
} }
@ -269,7 +262,7 @@ class UploadManager extends EventEmitter {
attempt, attempt,
maxAttempts maxAttempts
}); });
await this._sleep(3000, signal); await this._sleep(2500, signal);
} }
const jobStart = Date.now(); const jobStart = Date.now();

View File

@ -577,7 +577,6 @@ ipcMain.handle('start-upload', (_event, payload) => {
// This ensures webContents.send() calls from upload events // This ensures webContents.send() calls from upload events
// are not interleaved with the handle() response. // are not interleaved with the handle() response.
process.nextTick(() => { process.nextTick(() => {
if (!uploadManager) { debugLog('nextTick: uploadManager was nulled before startBatch'); return; }
debugLog('nextTick: calling startBatch now'); debugLog('nextTick: calling startBatch now');
uploadManager.startBatch(tasks).catch((err) => { uploadManager.startBatch(tasks).catch((err) => {
debugLog(`startBatch REJECTED: ${err && err.stack ? err.stack : err}`); debugLog(`startBatch REJECTED: ${err && err.stack ? err.stack : err}`);

View File

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

@ -691,7 +691,6 @@ function sortQueueJobs(jobs) {
else if (key === 'host') cmp = a.hoster.localeCompare(b.hoster); else if (key === 'host') cmp = a.hoster.localeCompare(b.hoster);
else if (key === 'status') cmp = getStatusOrder(a.status) - getStatusOrder(b.status); else if (key === 'status') cmp = getStatusOrder(a.status) - getStatusOrder(b.status);
else if (key === 'speed') cmp = (a.speedKbs || 0) - (b.speedKbs || 0); else if (key === 'speed') cmp = (a.speedKbs || 0) - (b.speedKbs || 0);
else if (key === 'progress') cmp = (a.progress || 0) - (b.progress || 0);
return cmp * factor; return cmp * factor;
}); });
} }
@ -1952,11 +1951,12 @@ async function loadHistory() {
for (const file of (batch.files || [])) { for (const file of (batch.files || [])) {
for (const result of (file.results || [])) { for (const result of (file.results || [])) {
if (result.status === 'aborted' || result.status === 'error') continue; if (result.status === 'aborted' || result.status === 'error') continue;
const isError = result.status === 'error';
historyRowsData.push({ historyRowsData.push({
date: dt.text, dateTs: dt.ts, date: dt.text, dateTs: dt.ts,
filename: file.name || '', host: result.hoster || '', filename: file.name || '', host: result.hoster || '',
link: result.download_url || result.embed_url || '', link: isError ? `[Fehler] ${result.error || ''}` : (result.download_url || result.embed_url || ''),
isError: false, order: order++ isError, order: order++
}); });
} }
} }
@ -2135,7 +2135,6 @@ function setupListeners() {
const tr = e.target.closest('.recent-file-row'); const tr = e.target.closest('.recent-file-row');
if (!tr) return; if (!tr) return;
e.preventDefault(); e.preventDefault();
e.stopPropagation();
const id = parseInt(tr.dataset.order, 10); const id = parseInt(tr.dataset.order, 10);
if (!selectedRecentIds.has(id)) { if (!selectedRecentIds.has(id)) {
selectedRecentIds.clear(); selectedRecentIds.clear();

View File

@ -84,7 +84,7 @@
<th class="col-elapsed">Zeit</th> <th class="col-elapsed">Zeit</th>
<th class="col-remaining">Rest</th> <th class="col-remaining">Rest</th>
<th class="col-speed sortable" data-sort="speed">Speed</th> <th class="col-speed sortable" data-sort="speed">Speed</th>
<th class="col-progress sortable" data-sort="progress">Fortschritt</th> <th class="col-progress">Fortschritt</th>
</tr> </tr>
</thead> </thead>
<tbody id="queueBody"></tbody> <tbody id="queueBody"></tbody>