Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: torrent stats panic #737

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion internal/protocol/bt/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
continue
}

stats := f.torrent.Stats()
stats := f.torrentStats()

Check warning on line 298 in internal/protocol/bt/fetcher.go

View check run for this annotation

Codecov / codecov/patch

internal/protocol/bt/fetcher.go#L298

Added line #L298 was not covered by tests
f.data.SeedBytes = lastData.SeedBytes + stats.BytesWrittenData.Int64()

// Check is download complete, if not don't check and stop seeding
Expand Down Expand Up @@ -332,6 +332,17 @@
}
}

// Get torrent stats maybe panic, see https://github.com/anacrolix/torrent/issues/972
func (f *Fetcher) torrentStats() torrent.TorrentStats {
defer func() {
if r := recover(); r != nil {

Check warning on line 338 in internal/protocol/bt/fetcher.go

View check run for this annotation

Codecov / codecov/patch

internal/protocol/bt/fetcher.go#L336-L338

Added lines #L336 - L338 were not covered by tests
// ignore panic
}
}()

return f.torrent.Stats()

Check warning on line 343 in internal/protocol/bt/fetcher.go

View check run for this annotation

Codecov / codecov/patch

internal/protocol/bt/fetcher.go#L343

Added line #L343 was not covered by tests
}

func (f *Fetcher) UploadedBytes() int64 {
return f.data.SeedBytes
}
Expand Down
4 changes: 2 additions & 2 deletions ui/flutter/lib/app/modules/create/views/create_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,8 @@ class CreateView extends GetView<CreateController> {
style:
ElevatedButton.styleFrom(shape: const StadiumBorder())
.copyWith(
backgroundColor: WidgetStateProperty.all(
Get.theme.colorScheme.surface)),
backgroundColor: MaterialStateProperty.all(
Get.theme.colorScheme.background)),
onPressed: () {
Get.back();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ class ExtensionView extends GetView<ExtensionController> {
style:
ElevatedButton.styleFrom(shape: const StadiumBorder())
.copyWith(
backgroundColor: WidgetStateProperty.all(
Get.theme.colorScheme.surface)),
backgroundColor: MaterialStateProperty.all(
Get.theme.colorScheme.background)),
onPressed: () {
Get.back();
},
Expand Down
2 changes: 1 addition & 1 deletion ui/flutter/lib/app/views/open_in_new.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class OpenInNew extends StatelessWidget {
launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication);
},
style: ElevatedButton.styleFrom(
backgroundColor: Get.theme.colorScheme.surface,
backgroundColor: Get.theme.colorScheme.background,
),
child: Row(
mainAxisSize: MainAxisSize
Expand Down
Loading