Skip to content

[bug] v0.10.5: fileConflict=OVERWRITE (use existing files) never adopts a complete in-place download (v1 torrent with path-style file name) — same via CLI --overwrite #686

Open

Description

@lianlonggang

Bug

fileConflict=OVERWRITE ("use existing files") never adopts an in-place download of another client's for a v1 torrent whose file entry is a path (folder/file.ext), on v0.10.5 (revision 0759370, Docker ghcr.io/linroid/ketch:latest, linux/arm64). The check completes in ~1.2 s reporting 0/N pieces verified — it reads nothing — and the torrent downloads from the network beside the complete file instead, creating name (1) folders.

Per #672, the feature is supposed to work in apps, CLI and SDK. It fails identically via CLI (ketch add --overwrite <magnet> /downloads), so this is engine-level, not REST-level.

Repro (server + real torrent)

  1. Download a magnet with another client until complete (used aria2/motrix). Torrent: btih=b55f3b1f24c72fb700417e0c6e1f1eb4d1c46c27, v1, single file, but info.name and the file entry carry a folder prefix (复仇者联盟4…6v电影…/<file>.mp4). Piece length 1 MB, 5560 pieces.
  2. Verify the on-disk file is the torrent data: exported metainfo via GET /api/torrents/{id}/export?metainfo=true, sha1-checked pieces 0,1,2, mid, last-1, last against the file — all match.
  3. Place the file at the exact path Ketch chose for the task (<dir>/<folder>/<file>.mp4), add the task with fileConflict: "overwrite":
    POST /api/tasks {"url":"<magnet>","directory":"/downloads","fileConflict":"overwrite"}
    
  4. Log shows:
    [TorrentSession] Checking files for taskId=… (b55f3b1f24c7)
    [TorrentSession] Checked files …: 0/5560 pieces verified, 0/5829734547 bytes   # 1.2 s later — file never opened
    
    The task then creates … (1).net …/ and starts downloading over the network.
  5. Same via CLI inside the server container: ketch add --overwrite <magnet> /downloads → same 0/5560, same name (1) behavior.

Also tried: directory set to the containing folder itself → still 0/5560.

Expected

#672: "Ketch checks every file against the torrent's hashes, keeps the pieces that match, downloads the rest over what differs, and completes, at once when everything matches." Here it should have completed instantly with zero peer bytes.

Suspect

For a v1 torrent whose single file name is folder/file.ext, the existing-file probe may look at the wrong path (e.g. <dir>/<folder>/ treated as multi-file layout vs <dir>/<file> for the single-file in-place rule — "a v1 torrent uses a single file in place"). The check returning in ~1 s on a 5.4 GB file suggests it stats nothing rather than failing hashes.

Env

Ketch server v0.10.5 in Docker on Raspberry Pi 5 (aarch64, Debian 12), torrent state clean (no other tasks, no unfinished reservations — verified after deleting all tasks and wiping .ketch-* checkpoints).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions