- Always force re-download once when both JVM and legacy extractors fail
(suggestRedownload=true), regardless of valid archive signature
- Add autoRecoveredForRedownload Set for loop protection (one attempt per archive)
- Clear loop protection on package reset (clearHybridArchiveState)
- Previous sibling-items check failed when other episodes were already
cleaned up after hybrid extraction
- Lower mini-download retry threshold from 100KB to 5KB
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Retry extraction with 2.5s delay on CRC/password errors (Windows file handle race)
- Improve auto-recovery: force re-download when known password fails (content corruption)
- Expand auto-recovery to wrong_password category for encrypted RAR5
- Add fsync after download for pre-allocated files
- Fix permanent extraction failure loop for archives with valid headers but corrupt content
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Early-exit now also uses raw Content-Length as fallback when
totalBytes is unknown (provider returned fileSize=0)
- Stall handler checks if file is already complete on disk before
deleting and retrying — prevents re-download loop for files that
finished but server delayed closing the connection
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add scheduler generation counter to prevent stale scheduler from
continuing after stop/start cycle
- Guard processItem stop-abort handler: skip status overwrite when a
new start() has already re-activated the session
- Yield in start() after recoverRetryableItems to let pending abort
handlers complete before evaluating item states
- Add test: rapid stop → disable provider → start must resolve
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Files with valid RAR/7z/ZIP signature are not corrupt (wrong password),
only files with invalid signature get force-redownloaded.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Trust extractor CRC verdict over file size checks
- Re-queue incomplete downloads instead of just warning
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Items incorrectly marked as "completed" by the old 50% recovery threshold
persist in the session file across updates. On startup, check all completed
items: if the file on disk is smaller than expected totalBytes, reset to
"queued" so it gets re-downloaded. Also reset items whose files are missing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Two bugs in findReadyArchiveSets disk-fallback:
1. Failed items were explicitly excluded from the blocking check
(status !== "failed"), so partial downloads with "failed" status
would not block extraction. Now ANY non-completed item blocks.
2. The disk size check was only > 10 KB, allowing 627 MB partial
files of 1001 MB archives to pass. Now requires the file to be
within one allocation unit of the item's expected totalBytes.
Added findItemByDiskPath helper to look up the owning item for a
file on disk and get its expected size.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Item-Recovery incorrectly marked partially downloaded files as "completed"
when the file size was >= 50% of expected size. A 627 MB partial download
of a 1001 MB file (62.7%) would pass the check and trigger hybrid
extraction on incomplete RAR archives.
Fix: require file to be within one allocation unit (4 KB) of the expected
size instead of 50%. Also add a pre-allocation guard: if the file appears
to be at the expected size but downloadedBytes is significantly behind
(< 95%), skip recovery (likely a pre-allocated sparse file from a crash).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Detect items whose targetPath has a " (N)" suffix from the previous
duplicate filename bug and rename them back to the original filename.
This fixes extraction failures for RAR split archives that were
downloaded with (1) suffix before v1.7.19.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
After restart, reservedTargetPaths (in-memory) was empty so claimTargetPath
could not distinguish between "file belongs to this item" and "file belongs
to another item". The naive fix (allow overwrite if unclaimed) would have
risked overwriting completed files from other items.
Proper fix: restore reservedTargetPaths from persisted session data on init.
This way each item's targetPath is correctly claimed, and claimTargetPath
can safely reuse the item's own file while protecting other items' files.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When the app restarts (or updates) while downloads are in progress,
partial files remain on disk but reservedTargetPaths (in-memory) is empty.
claimTargetPath treated the unclaimed-but-existing file as a conflict and
appended (1) to the filename, breaking RAR split archive extraction.
Fix: if a file exists on disk but no other item has reserved the path,
allow overwriting instead of creating a duplicate.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Shelve (15+ failures) now mimics manual stop/start behavior:
- Clears item.provider for fresh provider selection on retry
- Resets provider circuit breaker (providerFailures) for the old provider
- Reduces shelve duration from 5 min to 90s since the issue is stale
provider state, not a timing problem (manual restart works instantly)
Also adds comprehensive session-load logging:
- Logs package/item count on every session file read
- Logs errors when session file parsing fails (was silent before)
- Safety net: if primary session is empty but backup has packages,
automatically restores from backup
- Logs shutdown save with package/item counts
- Logs DownloadManager init state and cleanup policy
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The inner unrestrict error handler still called recordProviderFailure()
for hosterNotAvailable errors, causing provider-level cooldown escalation
(up to 180s) even though the issue is hoster-side, not provider-side.
This made auto-retry stall while manual reset worked instantly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
hosterNotAvailable was added to isTemporaryUnrestrictError which
triggered aggressive provider-level cooldowns (up to 180s) that
blocked ALL items for the affected provider. Since items kept
failing, the cooldown never expired (15-min reset threshold never
reached), causing retries to effectively stall.
Fix: remove hosterNotAvailable from isTemporaryUnrestrictError.
It still gets normal unrestrict retry with item-level backoff
(5s -> 120s) via isUnrestrictFailure, but without provider-wide
cooldown blocking other items.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move hosterNotAvailable from isPermanentLinkError to
isTemporaryUnrestrictError — hoster being unavailable is usually
transient (overload, maintenance) and should be retried with backoff
instead of immediately failing as "Link ungültig".
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- SCENE_EPISODE_RE/JOINED_RE: use (?!\d) lookahead instead of requiring
separator after episode number, so filenames like s09e06rrp now match
- MKV-Sammelordner: skip 0-byte files from failed/partial extractions
- MKV-Sammelordner: detect same-name same-size duplicates in target dir
and skip instead of creating (2) copies; remove duplicate source file
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Retry failed wrong_password archives serially after parallel extraction
to recover from CRC mismatches caused by concurrent UnRAR I/O contention
- Stop resetting sessionDownloadedBytes on start/resume so the session
total accurately reflects all bytes downloaded since app launch
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Daily traffic limits:
- Per-provider daily download limit (configurable in GB per provider)
- Per Debrid-Link API key daily limit (individual limits per key)
- Usage tracking with automatic daily reset at midnight
- Provider is skipped when daily limit reached, falls back to next provider
- Reset button per provider and per Debrid-Link key in account settings
- Hoster routing skips daily-limited providers gracefully
Debrid-Link multi-key improvements:
- Keys now display with labels (#1, #2...) and masked tokens in account list
- Option to show detailed per-key view with individual usage stats
- Keys that hit their daily limit are automatically skipped
- providerAccountId/providerAccountLabel stored per download item
Auto-sort packages by progress:
- Active packages automatically sorted to top during downloads
- Sorted by completion ratio, then downloaded bytes
- Toggle in settings (autoSortPackagesByProgress)
UI polish:
- Package column headers: flatter, more transparent design
- LinkSnappy mode label: "Login" renamed to "Web"
- Account list: new toggle for detailed Debrid-Link key display
- Account usage stats section with warning styling
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- extractor: detect UnRAR "Cannot create...\..." error (archive with
leading-backslash internal paths) and retry in flat mode (-e) which
strips all paths and avoids the invalid double-separator on Windows
- types/download-manager: add providerLabel field to DownloadItem,
store full label (e.g. "Debrid-Link #1") set at unrestrict time
- App: display providerLabel in Service column (falls back to generic
provider name if label not yet set)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sanitizeFilename() is now applied before constructing outputDir and
extractDir, so names like "TMSF/4SF" no longer produce broken Windows paths.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When a pending item has neither targetPath nor fileName (e.g. after a
reset before re-unrestrict), it is invisible to pendingItemStatus and
the disk-fallback could incorrectly start extraction with a partial file.
Add a guard that skips disk-fallback for any archive set if the package
contains such an untracked pending item.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Clear item.provider on stop/restart so provider order/routing changes
are respected on next download attempt
- Reset item.provider for all non-completed items when providerOrder or
hosterRouting changes in settings
- Cancel scheduled-start timer when queue is started manually
- Track disk-fallback hybrid-extract archives per session to prevent
infinite post-processing loop
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
MKV library collection now filters out sample files before moving.
Files in "sample"/"samples" directories and files with "sample" in
their name are excluded. This prevents duplicate "(2)" entries in
the library folder caused by samples having the same base name as
the real episodes (just different casing from the archive).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace BrowserWindow-based login flow with Netscape cookie file import
for BestDebrid authentication. Cloudflare Turnstile captcha cannot be
solved in Electron's embedded browser, so users export cookies from
their real browser and import them here.
- Rewrite bestdebrid-web.ts: remove BrowserWindow/CDP code, add
parseNetscapeCookieFile() and importCookiesFromFile()
- Add file picker dialog for .txt cookie files in main IPC handler
- Update IPC channel from OPEN_BESTDEBRID_LOGIN to IMPORT_BESTDEBRID_COOKIES
- Update preload bridge and renderer UI with cookie import button
- Fix pLabel scope in downloadToFile (pass as parameter from processItem)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The running download status (e.g. "Download läuft", "Warte auf
Festplatte") now shows the full provider label including the source
mode, e.g. "Mega-Debrid (API)" instead of just "Mega-Debrid".
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When hybrid extraction handled all archives, extractedCount stayed 0
causing all cleanup steps (archive deletion, resume state, link/sample
removal, empty dir pruning, auto-rename, nested extraction) to be
bypassed. Extended conditions to also trigger on alreadyMarkedExtracted.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace extractSlow() per-item extraction with IInArchive.extract() bulk API
in 7-Zip-JBinding. Solid RAR archives no longer re-decode from the beginning
for each item, bringing extraction speed close to native WinRAR/7z.exe (~375 MB/s
instead of ~43 MB/s).
- Add BulkExtractCallback implementing both IArchiveExtractCallback and
ICryptoGetTextPassword for proper password handling during bulk extraction.
- Fix resolveArchiveItemsFromList with multi-level fallback matching:
1. Pattern match (multipart RAR, split ZIP/7z, generic splits)
2. Exact filename match (case-insensitive)
3. Stem-based fuzzy match (handles debrid service filename modifications)
4. Single-item archive fallback
- Simplify caching from Set+Array workaround back to simple Map<string, T>
(the original "caching failure" was caused by resolveArchiveItemsFromList
returning empty arrays, not by Map/Set/Object data structure bugs).
- Add comprehensive tests for archive item resolution (14 test cases)
and JVM extraction progress callbacks (2 test cases).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- JVM extractor now supports --daemon mode: starts once, processes
multiple archives via stdin JSON protocol, eliminating ~5s JVM boot
per archive
- TypeScript side: daemon manager starts JVM once, sends requests via
stdin, falls back to spawning new process if daemon is busy
- Fix extraction progress caching: replaced Object.create(null) + in
operator with Set<string> + linear Array scan — both Map.has() and
the in operator mysteriously failed to find keys that were just set
- Daemon auto-shutdown on app quit via shutdownDaemon() in before-quit
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace Map-based archive item cache with plain Object.create(null)
to work around mysterious Map.has() returning false despite set()
being called with the same key — this caused resolveArchiveItems
to run on every 1.1s pulse instead of being cached, preventing
extraction progress (Entpacken X%) from ever showing in the UI
- Apply same fix to both hybrid and full extraction paths
- Increase JVM heap from 512MB to 1GB for better extraction throughput
- Use SerialGC for faster JVM startup on short-lived extract processes
- Add download lifecycle logging (package add + item download start)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Log when packages are added (count + names)
- Log when individual item downloads start (filename, size, provider)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>