block file info for incomplete files
This commit is contained in:
@@ -59,10 +59,17 @@ def _torrent_file_remote_path(profile: dict, torrent_hash: str, index: int) -> t
|
||||
if selected is None:
|
||||
available = ", ".join(str(f.get("index")) for f in files[:20]) or "none"
|
||||
raise ValueError(f"File index {index} not found. Available indexes: {available}")
|
||||
|
||||
base = _remote_clean_path(_torrent_data_path(c, torrent_hash))
|
||||
rel = str(selected.get("path") or "").lstrip("/")
|
||||
if len(files) == 1 and base and not base.endswith("/"):
|
||||
path = base
|
||||
|
||||
# Note: rTorrent can report d.base_path as either the payload file or the
|
||||
# containing data directory for a one-file torrent. Keep both existing
|
||||
# layouts working and avoid treating a directory as the media file.
|
||||
if len(files) == 1 and base and rel:
|
||||
base_name = posixpath.basename(base.rstrip("/"))
|
||||
rel_name = posixpath.basename(rel.rstrip("/"))
|
||||
path = base if base_name == rel_name else _remote_join(base, rel)
|
||||
else:
|
||||
path = _remote_join(base, rel)
|
||||
return selected, path
|
||||
|
||||
Reference in New Issue
Block a user