chore: drop parseAriaProgress

This commit is contained in:
Martin Wimpress 2024-06-26 15:55:14 +01:00 committed by Martin Wimpress
parent 9d596b6acc
commit 7a21dd2898
1 changed files with 1 additions and 16 deletions

View File

@ -32,7 +32,6 @@ class Downloader extends StatefulWidget {
class _DownloaderState extends State<Downloader> {
final notificationsClient = NotificationsClient();
final wgetPattern = RegExp("( [0-9.]+%)");
final ariaPattern = RegExp("([0-9.]+%)");
late final Stream<double> _progressStream;
bool _downloadFinished = false;
var controller = StreamController<double>();
@ -55,17 +54,6 @@ class _DownloaderState extends State<Downloader> {
}
}
void parseAriaProgress(String line) {
var matches = ariaPattern.allMatches(line).toList();
if (matches.isNotEmpty) {
var percent = matches[0].group(1);
if (percent != null) {
var value = double.parse(percent.replaceAll('%', '')) / 100.0;
controller.add(value);
}
}
}
Stream<double> progressStream() {
var options = [widget.operatingSystem.code, widget.version.version];
if (widget.option != null) {
@ -76,8 +64,6 @@ class _DownloaderState extends State<Downloader> {
process.stderr.transform(utf8.decoder).forEach(parseWgetProgress);
} else if (widget.option!.downloader == 'zsync') {
controller.add(-1);
} else if (widget.option!.downloader == 'aria2c') {
process.stderr.transform(utf8.decoder).forEach(parseAriaProgress);
}
process.exitCode.then((value) {
@ -132,8 +118,7 @@ class _DownloaderState extends State<Downloader> {
stream: _progressStream,
builder: (context, AsyncSnapshot<double> snapshot) {
var data = !snapshot.hasData ||
widget.option!.downloader != 'wget' ||
widget.option!.downloader != 'aria2c'
widget.option!.downloader != 'wget'
? null
: snapshot.data;
return Column(