refactor: adapt parseWgetProgress to parseCurlProgress
Since Quickemu 4.9.3 quickget downloads everything except Ubuntu daily images with curl, via the web_get() function internal to quickget. This change adapts the progress parsing to curl's progress output and accounts for a bug in quickget where it stopped reporting if wget/curl is the external download tool.
This commit is contained in:
parent
7a21dd2898
commit
a8ada5a40a
|
|
@ -34,7 +34,7 @@ Future<List<OperatingSystem>> loadOperatingSystems(bool showUbuntus) async {
|
|||
Tuple5 supportedVersion;
|
||||
if (chunks.length == 4) // Legacy version of quickget
|
||||
{
|
||||
supportedVersion = Tuple5.fromList([...chunks, "wget"]);
|
||||
supportedVersion = Tuple5.fromList([...chunks, "curl"]);
|
||||
} else {
|
||||
var t5 = [chunks[0], chunks[1], chunks[2], chunks[3], chunks[4]].toList();
|
||||
supportedVersion = Tuple5.fromList(t5);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class Downloader extends StatefulWidget {
|
|||
|
||||
class _DownloaderState extends State<Downloader> {
|
||||
final notificationsClient = NotificationsClient();
|
||||
final wgetPattern = RegExp("( [0-9.]+%)");
|
||||
final curlPattern = RegExp("( [0-9.]+%)");
|
||||
late final Stream<double> _progressStream;
|
||||
bool _downloadFinished = false;
|
||||
var controller = StreamController<double>();
|
||||
|
|
@ -43,8 +43,8 @@ class _DownloaderState extends State<Downloader> {
|
|||
super.initState();
|
||||
}
|
||||
|
||||
void parseWgetProgress(String line) {
|
||||
var matches = wgetPattern.allMatches(line).toList();
|
||||
void parseCurlProgress(String line) {
|
||||
var matches = curlPattern.allMatches(line).toList();
|
||||
if (matches.isNotEmpty) {
|
||||
var percent = matches[0].group(1);
|
||||
if (percent != null) {
|
||||
|
|
@ -60,9 +60,9 @@ class _DownloaderState extends State<Downloader> {
|
|||
options.add(widget.option!.option);
|
||||
}
|
||||
Process.start('quickget', options).then((process) {
|
||||
if (widget.option!.downloader == 'wget') {
|
||||
process.stderr.transform(utf8.decoder).forEach(parseWgetProgress);
|
||||
} else if (widget.option!.downloader == 'zsync') {
|
||||
if (widget.option!.downloader != 'zsync') {
|
||||
process.stderr.transform(utf8.decoder).forEach(parseCurlProgress);
|
||||
} else {
|
||||
controller.add(-1);
|
||||
}
|
||||
|
||||
|
|
@ -118,7 +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 != 'curl'
|
||||
? null
|
||||
: snapshot.data;
|
||||
return Column(
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class DownloadLabel extends StatelessWidget {
|
|||
? Text(context.t('Download finished.'))
|
||||
: data != null
|
||||
? downloader != 'zsync'
|
||||
? downloader == 'wget' || downloader == 'aria2c'
|
||||
? downloader == 'curl' || downloader == ''
|
||||
? Text(context.t('Downloading... {0}%',
|
||||
args: [(data! * 100).toInt()]))
|
||||
: Text(context.t('{0} Mbs downloaded', args: [data!]))
|
||||
|
|
|
|||
Loading…
Reference in New Issue