You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+19Lines changed: 19 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.
5
5
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
8
+
## UNRELEASED (YYYY-MM-DD)
9
+
10
+
This release focuses on supporting listing files contained in torrents. This is not implemented for magnet files, but is implemented for `TorrentFile` and will be implemented in [hightorrent_api](https://github.com/angrynode/hightorrent_api) for the QBittorrent backend.
11
+
12
+
### Added
13
+
14
+
-`DecodedInfo.piece_length` contains the torrent piece length in bytes, with a maximum supported size of `536854528` like in libtorrent
15
+
-`TorrentContent` represents a file in a torrent ; `ToTorrentContent` is a trait enabling specialized representations to be turned into a backend-agnostic `TorrentContent` ; padding files are ignored when producing a list of content files
16
+
-`DecodedTorrent::files()` produces the file list in the torrent (only v1 torrents supported for now)
17
+
18
+
### Changed
19
+
20
+
- Not having a `piece length` info field in a torrent produces an error ; so does having a size exceeding `536854528` bytes
21
+
- Having `/` or `..` in a content file part produces a `TorrentFileError::InvalidContentPath`
22
+
23
+
### Meta
24
+
25
+
- Added more test cases from arvidn/libtorrent to make sure we don't allow parsing invalid torrents
Copy file name to clipboardExpand all lines: README.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,6 +39,10 @@ Contributions are welcome. Here are the steps to make sure your contribution get
39
39
40
40
If you don't have those dependencies (`just`, `cargo-rdme`), you can setup a temporary development environment with [Nix](https://nixos.org/) by running `nix develop`.
41
41
42
+
# Running tests
43
+
44
+
From the repository root, run `cargo test`. To run advanced tests using rust nightly as used in CI, run `scripts/pre-commit.sh`. To run the test verifying that error cases from libtorrent are properly handled (which is normally ignored), run `cargo test -- --ignored`.
45
+
42
46
# Possible improvements for v1
43
47
44
48
-[x] hand-implement errors to remove snafu dependency
@@ -48,6 +52,7 @@ If you don't have those dependencies (`just`, `cargo-rdme`), you can setup a tem
48
52
-[ ] implement MultiTarget filtering, including boolean logic (AND/OR/XOR)
49
53
-[ ] provide more information for TorrentFile (eg. files list)
50
54
-[ ] consider replacing Torrent with a trait
55
+
-[ ] implement more libtorrent tests (28/41 wrongful successes as of 03/28/2025)
/// Maximum size of the `piece length` entry in info dict for V2 torrents.
12
+
///
13
+
/// Magic number copied over [from libtorrent](https://github.com/arvidn/libtorrent/blob/1b9dc7462f22bc1513464d01c72281280a6a5f97/include/libtorrent/file_storage.hpp#L246).
14
+
pubconstMAXIMUM_PIECE_LENGTH:u32 = 536854528;
9
15
10
16
/// Error occurred during parsing a [`TorrentFile`](crate::torrent_file::TorrentFile).
11
17
#[derive(Clone,Debug,PartialEq)]
@@ -16,6 +22,9 @@ pub enum TorrentFileError {
16
22
NotATorrent{reason:String},
17
23
WrongVersion{version:u64},
18
24
InvalidHash{source:InfoHashError},
25
+
InvalidContentPath{path:String},
26
+
MissingPieceLength,
27
+
BadPieceLength{piece_length:u32},
19
28
}
20
29
21
30
impl std::fmt::DisplayforTorrentFileError{
@@ -32,6 +41,15 @@ impl std::fmt::Display for TorrentFileError {
32
41
"Wrong torrent version: {version}, only v1 and v2 are supported)"
0 commit comments