Skip to content

Commit

Permalink
add inactiveSeedingTimeLimit field
Browse files Browse the repository at this point in the history
  • Loading branch information
yosemiteyss committed Sep 10, 2024
1 parent 1e80836 commit f6cc5b5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/src/v2/torrents/torrents_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -400,19 +400,22 @@ class TorrentsController {

/// Set torrent share limit
/// [torrents] - The torrents to set the share limit of.
/// [ratioLimit] - the max ratio the torrent should be seeded until.
/// [seedingTimeLimit] - the max amount of time (minutes) the torrent should be seeded.
/// [ratioLimit] - The maximum seeding ratio for the torrent.
/// [seedingTimeLimit] - The maximum seeding time (minutes) for the torrent.
/// [inactiveSeedingTimeLimit] - The maximum amount of time (minutes) the torrent is allowed to seed while being inactive.
Future<void> setShareLimit({
required Torrents torrents,
required RatioLimit ratioLimit,
required RatioLimit seedingTimeLimit,
required RatioLimit inactiveSeedingTimeLimit,
}) async {
await _apiClient.post(
'/torrents/setShareLimits',
body: {
'hashes': torrents.toRequestString(),
'ratioLimit': ratioLimit.ratio,
'seedingTimeLimit': seedingTimeLimit.ratio,
'inactiveSeedingTimeLimit': inactiveSeedingTimeLimit.ratio,
},
);
}
Expand Down
6 changes: 6 additions & 0 deletions test/v2/torrents/torrents_controller_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ void main() {
torrents: const Torrents.all(),
ratioLimit: const RatioLimit.none(),
seedingTimeLimit: const RatioLimit.none(),
inactiveSeedingTimeLimit: const RatioLimit.none(),
);
expect(
(fakeApiClient.getBody() as Map<String, dynamic>?)?['ratioLimit'],
Expand All @@ -768,6 +769,7 @@ void main() {
torrents: const Torrents.all(),
ratioLimit: const RatioLimit(2),
seedingTimeLimit: const RatioLimit.none(),
inactiveSeedingTimeLimit: const RatioLimit.none(),
);
expect(
(fakeApiClient.getBody() as Map<String, dynamic>?)?['ratioLimit'],
Expand All @@ -779,6 +781,7 @@ void main() {
torrents: const Torrents.all(),
ratioLimit: const RatioLimit.global(),
seedingTimeLimit: const RatioLimit.none(),
inactiveSeedingTimeLimit: const RatioLimit.none(),
);
expect(
(fakeApiClient.getBody() as Map<String, dynamic>?)?['ratioLimit'],
Expand All @@ -793,6 +796,7 @@ void main() {
torrents: const Torrents.all(),
ratioLimit: const RatioLimit.none(),
seedingTimeLimit: const RatioLimit.none(),
inactiveSeedingTimeLimit: const RatioLimit.none(),
);
expect(
(fakeApiClient.getBody() as Map<String, dynamic>?)?['seedingTimeLimit'],
Expand All @@ -804,6 +808,7 @@ void main() {
torrents: const Torrents.all(),
ratioLimit: const RatioLimit.none(),
seedingTimeLimit: const RatioLimit(2),
inactiveSeedingTimeLimit: const RatioLimit.none(),
);
expect(
(fakeApiClient.getBody() as Map<String, dynamic>?)?['seedingTimeLimit'],
Expand All @@ -815,6 +820,7 @@ void main() {
torrents: const Torrents.all(),
ratioLimit: const RatioLimit.none(),
seedingTimeLimit: const RatioLimit.global(),
inactiveSeedingTimeLimit: const RatioLimit.none(),
);
expect(
(fakeApiClient.getBody() as Map<String, dynamic>?)?['seedingTimeLimit'],
Expand Down

0 comments on commit f6cc5b5

Please sign in to comment.