mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-17 05:43:41 +00:00
fix: torrent stats panic (#737)
This commit is contained in:
4 files changed
+17
-6
No files matched your search
@@ -295,7 +295,7 @@ func (f *Fetcher) doUpload(fromUpload bool) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
stats := f.torrent.Stats()
|
stats := f.torrentStats()
|
||||||
f.data.SeedBytes = lastData.SeedBytes + stats.BytesWrittenData.Int64()
|
f.data.SeedBytes = lastData.SeedBytes + stats.BytesWrittenData.Int64()
|
||||||
|
|
||||||
// Check is download complete, if not don't check and stop seeding
|
// Check is download complete, if not don't check and stop seeding
|
||||||
@@ -332,6 +332,17 @@ func (f *Fetcher) doUpload(fromUpload bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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 {
|
||||||
|
// ignore panic
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
return f.torrent.Stats()
|
||||||
|
}
|
||||||
|
|
||||||
func (f *Fetcher) UploadedBytes() int64 {
|
func (f *Fetcher) UploadedBytes() int64 {
|
||||||
return f.data.SeedBytes
|
return f.data.SeedBytes
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -689,8 +689,8 @@ class CreateView extends GetView<CreateController> {
|
|||||||
style:
|
style:
|
||||||
ElevatedButton.styleFrom(shape: const StadiumBorder())
|
ElevatedButton.styleFrom(shape: const StadiumBorder())
|
||||||
.copyWith(
|
.copyWith(
|
||||||
backgroundColor: WidgetStateProperty.all(
|
backgroundColor: MaterialStateProperty.all(
|
||||||
Get.theme.colorScheme.surface)),
|
Get.theme.colorScheme.background)),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Get.back();
|
Get.back();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -335,8 +335,8 @@ class ExtensionView extends GetView<ExtensionController> {
|
|||||||
style:
|
style:
|
||||||
ElevatedButton.styleFrom(shape: const StadiumBorder())
|
ElevatedButton.styleFrom(shape: const StadiumBorder())
|
||||||
.copyWith(
|
.copyWith(
|
||||||
backgroundColor: WidgetStateProperty.all(
|
backgroundColor: MaterialStateProperty.all(
|
||||||
Get.theme.colorScheme.surface)),
|
Get.theme.colorScheme.background)),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Get.back();
|
Get.back();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class OpenInNew extends StatelessWidget {
|
|||||||
launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication);
|
launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication);
|
||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Get.theme.colorScheme.surface,
|
backgroundColor: Get.theme.colorScheme.background,
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize
|
mainAxisSize: MainAxisSize
|
||||||
|
|||||||
Reference in new issue
Block a user