Release v1.4.3 with unified controls and resilient retries
Build and Release / build (push) Has been cancelled
Build and Release / build (push) Has been cancelled
This commit is contained in:
@@ -130,7 +130,7 @@ export class AppController {
|
||||
return this.manager.getStartConflicts();
|
||||
}
|
||||
|
||||
public resolveStartConflict(packageId: string, policy: DuplicatePolicy): StartConflictResolutionResult {
|
||||
public async resolveStartConflict(packageId: string, policy: DuplicatePolicy): Promise<StartConflictResolutionResult> {
|
||||
return this.manager.resolveStartConflict(packageId, policy);
|
||||
}
|
||||
|
||||
|
||||
@@ -528,6 +528,7 @@ export class DownloadManager extends EventEmitter {
|
||||
}
|
||||
|
||||
public getStartConflicts(): StartConflictEntry[] {
|
||||
const hasFilesByExtractDir = new Map<string, boolean>();
|
||||
const conflicts: StartConflictEntry[] = [];
|
||||
for (const packageId of this.session.packageOrder) {
|
||||
const pkg = this.session.packages[packageId];
|
||||
@@ -546,7 +547,19 @@ export class DownloadManager extends EventEmitter {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.directoryHasAnyFiles(pkg.extractDir)) {
|
||||
if (!this.isPackageSpecificExtractDir(pkg)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const extractDirKey = pathKey(pkg.extractDir);
|
||||
const hasExtractedFiles = hasFilesByExtractDir.has(extractDirKey)
|
||||
? Boolean(hasFilesByExtractDir.get(extractDirKey))
|
||||
: this.directoryHasAnyFiles(pkg.extractDir);
|
||||
if (!hasFilesByExtractDir.has(extractDirKey)) {
|
||||
hasFilesByExtractDir.set(extractDirKey, hasExtractedFiles);
|
||||
}
|
||||
|
||||
if (hasExtractedFiles) {
|
||||
conflicts.push({
|
||||
packageId: pkg.id,
|
||||
packageName: pkg.name,
|
||||
@@ -557,7 +570,7 @@ export class DownloadManager extends EventEmitter {
|
||||
return conflicts;
|
||||
}
|
||||
|
||||
public resolveStartConflict(packageId: string, policy: DuplicatePolicy): StartConflictResolutionResult {
|
||||
public async resolveStartConflict(packageId: string, policy: DuplicatePolicy): Promise<StartConflictResolutionResult> {
|
||||
const pkg = this.session.packages[packageId];
|
||||
if (!pkg || pkg.cancelled) {
|
||||
return { skipped: false, overwritten: false };
|
||||
@@ -581,13 +594,16 @@ export class DownloadManager extends EventEmitter {
|
||||
}
|
||||
|
||||
if (policy === "overwrite") {
|
||||
try {
|
||||
fs.rmSync(pkg.extractDir, { recursive: true, force: true });
|
||||
} catch {
|
||||
// ignore
|
||||
const canDeleteExtractDir = this.isPackageSpecificExtractDir(pkg) && !this.isExtractDirSharedWithOtherPackages(pkg.id, pkg.extractDir);
|
||||
if (canDeleteExtractDir) {
|
||||
try {
|
||||
await fs.promises.rm(pkg.extractDir, { recursive: true, force: true });
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
try {
|
||||
fs.rmSync(pkg.outputDir, { recursive: true, force: true });
|
||||
await fs.promises.rm(pkg.outputDir, { recursive: true, force: true });
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
@@ -626,6 +642,31 @@ export class DownloadManager extends EventEmitter {
|
||||
return { skipped: false, overwritten: false };
|
||||
}
|
||||
|
||||
private isPackageSpecificExtractDir(pkg: PackageEntry): boolean {
|
||||
const expectedName = sanitizeFilename(pkg.name).toLowerCase();
|
||||
if (!expectedName) {
|
||||
return false;
|
||||
}
|
||||
return path.basename(pkg.extractDir).toLowerCase() === expectedName;
|
||||
}
|
||||
|
||||
private isExtractDirSharedWithOtherPackages(packageId: string, extractDir: string): boolean {
|
||||
const key = pathKey(extractDir);
|
||||
for (const otherId of this.session.packageOrder) {
|
||||
if (otherId === packageId) {
|
||||
continue;
|
||||
}
|
||||
const other = this.session.packages[otherId];
|
||||
if (!other || other.cancelled) {
|
||||
continue;
|
||||
}
|
||||
if (pathKey(other.extractDir) === key) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private async resolveQueuedFilenames(unresolvedByLink: Map<string, string[]>): Promise<void> {
|
||||
try {
|
||||
let changed = false;
|
||||
@@ -1496,6 +1537,8 @@ export class DownloadManager extends EventEmitter {
|
||||
|
||||
let freshRetryUsed = false;
|
||||
let stallRetries = 0;
|
||||
let genericErrorRetries = 0;
|
||||
const maxGenericErrorRetries = Math.max(2, REQUEST_RETRIES);
|
||||
while (true) {
|
||||
try {
|
||||
const unrestricted = await this.debridService.unrestrictLink(item.url);
|
||||
@@ -1633,6 +1676,18 @@ export class DownloadManager extends EventEmitter {
|
||||
} else {
|
||||
const errorText = compactErrorText(error);
|
||||
const shouldFreshRetry = !freshRetryUsed && isFetchFailure(errorText);
|
||||
const isHttp416 = /(^|\D)416(\D|$)/.test(errorText);
|
||||
if (isHttp416) {
|
||||
try {
|
||||
fs.rmSync(item.targetPath, { force: true });
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
this.releaseTargetPath(item.id);
|
||||
item.downloadedBytes = 0;
|
||||
item.totalBytes = null;
|
||||
item.progressPercent = 0;
|
||||
}
|
||||
if (shouldFreshRetry) {
|
||||
freshRetryUsed = true;
|
||||
try {
|
||||
@@ -1655,6 +1710,23 @@ export class DownloadManager extends EventEmitter {
|
||||
await sleep(450);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (genericErrorRetries < maxGenericErrorRetries) {
|
||||
genericErrorRetries += 1;
|
||||
item.status = "queued";
|
||||
item.fullStatus = `Fehler erkannt, Auto-Retry ${genericErrorRetries}/${maxGenericErrorRetries}`;
|
||||
item.lastError = errorText;
|
||||
item.attempts = 0;
|
||||
item.speedBps = 0;
|
||||
item.updatedAt = nowMs();
|
||||
active.abortController = new AbortController();
|
||||
active.abortReason = "none";
|
||||
this.persistSoon();
|
||||
this.emitState();
|
||||
await sleep(Math.min(1200, 300 * genericErrorRetries));
|
||||
continue;
|
||||
}
|
||||
|
||||
item.status = "failed";
|
||||
this.recordRunOutcome(item.id, "failed");
|
||||
item.lastError = errorText;
|
||||
@@ -1729,13 +1801,30 @@ export class DownloadManager extends EventEmitter {
|
||||
item.updatedAt = nowMs();
|
||||
return { retriesUsed: attempt - 1, resumable: true };
|
||||
}
|
||||
|
||||
try {
|
||||
fs.rmSync(effectiveTargetPath, { force: true });
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
item.downloadedBytes = 0;
|
||||
item.totalBytes = knownTotal && knownTotal > 0 ? knownTotal : null;
|
||||
item.progressPercent = 0;
|
||||
item.speedBps = 0;
|
||||
item.fullStatus = `Range-Konflikt (HTTP 416), starte neu ${Math.min(REQUEST_RETRIES, attempt + 1)}/${REQUEST_RETRIES}`;
|
||||
item.updatedAt = nowMs();
|
||||
this.emitState();
|
||||
if (attempt < REQUEST_RETRIES) {
|
||||
await sleep(280 * attempt);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
const text = await response.text();
|
||||
lastError = compactErrorText(text || `HTTP ${response.status}`);
|
||||
if (this.settings.autoReconnect && [429, 503].includes(response.status)) {
|
||||
this.requestReconnect(`HTTP ${response.status}`);
|
||||
}
|
||||
if (canRetryStatus(response.status) && attempt < REQUEST_RETRIES) {
|
||||
if (attempt < REQUEST_RETRIES) {
|
||||
item.fullStatus = `Serverfehler ${response.status}, retry ${attempt + 1}/${REQUEST_RETRIES}`;
|
||||
this.emitState();
|
||||
await sleep(350 * attempt);
|
||||
|
||||
+20
-7
@@ -404,6 +404,14 @@ export function App(): ReactElement {
|
||||
});
|
||||
};
|
||||
|
||||
const onStartPauseClick = async (): Promise<void> => {
|
||||
if (snapshot.session.running) {
|
||||
await performQuickAction(() => window.rd.togglePause());
|
||||
return;
|
||||
}
|
||||
await onStartDownloads();
|
||||
};
|
||||
|
||||
const onAddLinks = async (): Promise<void> => {
|
||||
await performQuickAction(async () => {
|
||||
await persistDraftSettings();
|
||||
@@ -661,9 +669,9 @@ export function App(): ReactElement {
|
||||
onDrop={onDrop}
|
||||
>
|
||||
<header className="top-header">
|
||||
<div className="header-spacer" />
|
||||
<div className="title-block">
|
||||
<h1>Debrid Download Manager</h1>
|
||||
<span>Multi-Provider Workflow</span>
|
||||
<h1>Multi Debrid Downloader</h1>
|
||||
</div>
|
||||
<div className="metrics">
|
||||
<div>{snapshot.speedText}</div>
|
||||
@@ -675,12 +683,17 @@ export function App(): ReactElement {
|
||||
</header>
|
||||
|
||||
<section className="control-strip">
|
||||
<div className="buttons">
|
||||
<button className="btn accent" disabled={!snapshot.canStart || actionBusy} onClick={() => { void onStartDownloads(); }}>Start</button>
|
||||
<button className="btn" disabled={!snapshot.canPause || actionBusy} onClick={() => { void performQuickAction(() => window.rd.togglePause()); }}>
|
||||
{snapshot.session.paused ? "Fortsetzen" : "Pause"}
|
||||
<div className="buttons buttons-left">
|
||||
<button
|
||||
className="btn accent"
|
||||
disabled={actionBusy || (!snapshot.canStart && !snapshot.canPause)}
|
||||
onClick={() => { void onStartPauseClick(); }}
|
||||
>
|
||||
{snapshot.session.running ? (snapshot.session.paused ? "Fortsetzen" : "Pause") : "Start"}
|
||||
</button>
|
||||
<button className="btn" disabled={!snapshot.canStop || actionBusy} onClick={() => { void performQuickAction(() => window.rd.stop()); }}>Stop</button>
|
||||
</div>
|
||||
<div className="buttons buttons-right">
|
||||
<button
|
||||
className="btn"
|
||||
disabled={actionBusy}
|
||||
@@ -695,7 +708,7 @@ export function App(): ReactElement {
|
||||
Alles leeren
|
||||
</button>
|
||||
<button className={`btn${snapshot.clipboardActive ? " btn-active" : ""}`} disabled={actionBusy} onClick={() => { void performQuickAction(() => window.rd.toggleClipboard()); }}>
|
||||
Clipboard {snapshot.clipboardActive ? "An" : "Aus"}
|
||||
Clipboard: {snapshot.clipboardActive ? "An" : "Aus"}
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
+40
-3
@@ -69,9 +69,18 @@ body,
|
||||
}
|
||||
|
||||
.top-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto 1fr;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.header-spacer {
|
||||
min-height: 1px;
|
||||
}
|
||||
|
||||
.title-block {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.title-block h1 {
|
||||
@@ -91,6 +100,7 @@ body,
|
||||
gap: 12px;
|
||||
color: var(--muted);
|
||||
font-size: 13px;
|
||||
justify-self: end;
|
||||
}
|
||||
|
||||
.control-strip {
|
||||
@@ -113,6 +123,11 @@ body,
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.buttons-right {
|
||||
margin-left: auto;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.btn {
|
||||
background: var(--button-bg);
|
||||
color: var(--text);
|
||||
@@ -677,6 +692,21 @@ td {
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.top-header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.header-spacer {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.title-block {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.control-strip {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
@@ -684,7 +714,14 @@ td {
|
||||
|
||||
.metrics {
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
align-items: center;
|
||||
justify-self: center;
|
||||
}
|
||||
|
||||
.buttons-right {
|
||||
width: 100%;
|
||||
margin-left: 0;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.settings-toolbar {
|
||||
|
||||
Reference in New Issue
Block a user