debridmediamanager / zurg-testing

A self-hosted Real-Debrid webdav server you can use with Infuse. Together with rclone it can mount your Real-Debrid torrent library into your filesystem and load it to Plex or Jellyfin.
416 stars 30 forks source link

RFC: Repairman #109

Closed yowmamasita closed 2 months ago

yowmamasita commented 3 months ago

Introduction

This RFC outlines procedures for handling repair issues with the Real-Debrid API during file processing in the zurg project.

Context

Two scenarios require repair actions:

  1. Link Discrepancy: Fewer links returned by the Real-Debrid API than selected files in a torrent.
  2. Unusable Links: Links that cannot be downloaded or streamed.

Scenarios Requiring Repair

Case 1: Link Discrepancy

When the API returns fewer links than selected files:

Case 2: Unusable Links

When a link cannot be used:

Definition of Broken Files

Files without a functional link are classified as "broken files" and require repair.

Repair Process

Repair Method 1: Redownload Entire Torrent

Repair Method 2: Redownload Cached Variations

Repair Method 3: Selective Redownload of Broken Files

Diagram

graph TD
    A[Identify Broken Files] --> B{Case 1: Link Discrepancy?}
    B -->|Yes| C[Unrestrict Links]
    C --> D[Match Links to Files]
    D --> E[500 Files Linked, 500 Broken]

    B -->|No| F{Case 2: Unusable Link?}
    F -->|Yes| G[Discard Unusable Link]
    G --> H[1 File Marked Broken]

    E --> I[Initiate Repair Process]
    H --> I[Initiate Repair Process]

    I --> J{Repair Method}
    J -->|Method 1| K[Redownload Entire Torrent]
    J -->|Method 2| L[Redownload Cached Variations]
    J -->|Method 3| M[Selective Redownload in Batches]

Conclusion

I will only implement methods 1 and 3 on the next version. Method 2 will come on the version after that. Feedback is welcome to improve the repair process.