From nobody Wed Feb 23 00:58:07 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 9AEE919DCC35; Wed, 23 Feb 2022 00:58:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4K3Hhb40Xdz4fgF; Wed, 23 Feb 2022 00:58:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645577887; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=UTVv0t4b9vYS1oW987uOM0jxnpM7NS3a+19ElSCtdj8=; b=eeb4F96zT44fOImFZc6OIt5gn3NqD4Xcaj7k8pC66bYyu68uBnskdhmOJIwNaxBrCfo0jB K6b7v1SOdLgfkYli65+8g8XA7PlYJWITAWi9qjgvwDThqXaRnTlrPo3q9arcWs6effEGdO YRMvjIxbSaHkc015bZE/D+EAAXG2Z81feAsp4jShYvRtvjR5cpbN00E87ltmSEH1VVpn+i lRE2tBgiucqcBAb/0Dj7GVJjRbze+cr/tGPkRIssBri7oUMBSkgLBq/LbXVdX93paGpMIc h9+uQQiVsH2PCcxSll9nZFI6yuSeeS4YZvvWgY2jW2NycKqFvugCY5q1QrwnHQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 64F4E68A9; Wed, 23 Feb 2022 00:58:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21N0w7o2033159; Wed, 23 Feb 2022 00:58:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21N0w7g3033158; Wed, 23 Feb 2022 00:58:07 GMT (envelope-from git) Date: Wed, 23 Feb 2022 00:58:07 GMT Message-Id: <202202230058.21N0w7g3033158@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alfonso S. Siciliano" Subject: git: 55af0f96d0fb - main - bsdinstall/distfetch: fix main bar percentage with errors List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asiciliano X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 55af0f96d0fb92e49fad0c63e7b062c419197459 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645577887; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=UTVv0t4b9vYS1oW987uOM0jxnpM7NS3a+19ElSCtdj8=; b=mPpmLnd1pTeIHeS3AgQGFXk+qsV2tR0UXMG2hbfSqfbjBHF3EyMIUOq4a6MtXx3VXAHgDy T+BuOxLL8ZwXg6GV156PawIczToQEa0vp0xVtSSkJzHGOyEeY23qs4eQgge+R4iHtsqwpp IcioGOBqM44HFIRlZJ9q05MEGNRZsEEq/cNEQo+IPTLYX5Br3RBzzILc36t2htJnhqQmgd OXNvpJRgVBI74ePx0ILUJH/rqnYdd6cvdpO43KoRpS90XcO68m4cuj8W79XbEj6OFoTV9M k9BSbOaPFU1x/NGX6meb+3Abc2OKi/swQZ8iiqoGLHokRw6L8slWYHvNg+887Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645577887; a=rsa-sha256; cv=none; b=aMXtaDLbYrHKqy0ayRHxd5R2/RnhR9SnUOO4CFyehm3n/dToWHcAhIvtr778IruBQm7tMY gg2kzbAmWvBUC1+OSfwvnqTqcGccYLpQvuh8cpO8Q/cajooYnuJEyOoDjYlcFE1EU39kPX LKodCnho0Bp4Ku3zxYanW0Dbku0zrlRynG8DWCc9ucQsmGV4H8h4/4Y0BTuNRwfP8lGG79 FR0AStd9/8ZDoyAyUdNpguU+8OsBMc9CsG/94sok5g1nzm1YrWdaphNwG7pxfDW5Ifrn2S zK0XOFS23BdxqxtJq2AQfTNqQYhwKbRXuxcPO+FPCkemZRDle2pDDrRL+Tw3Pw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by asiciliano: URL: https://cgit.FreeBSD.org/src/commit/?id=55af0f96d0fb92e49fad0c63e7b062c419197459 commit 55af0f96d0fb92e49fad0c63e7b062c419197459 Author: Alfonso S. Siciliano AuthorDate: 2022-02-23 00:54:51 +0000 Commit: Alfonso S. Siciliano CommitDate: 2022-02-23 00:54:51 +0000 bsdinstall/distfetch: fix main bar percentage with errors UI fix not related to the real fetching process, use 'nfiles' (instead of 'total files size') to compute main bar percentage if an error occurs: - fix: main bar greater than 100%, if an error occurs before fetching - fix: main bar less than 100%, if an error occurs during fetching - add: last mixedgauge, at least one dialog if a total failure occurs PR: 164094, 169748 Approved by: bapt (mentor) Review: https://reviews.freebsd.org/D33978 --- usr.sbin/bsdinstall/distfetch/distfetch.c | 33 ++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/usr.sbin/bsdinstall/distfetch/distfetch.c b/usr.sbin/bsdinstall/distfetch/distfetch.c index 5f262343720e..0510965dd4e7 100644 --- a/usr.sbin/bsdinstall/distfetch/distfetch.c +++ b/usr.sbin/bsdinstall/distfetch/distfetch.c @@ -113,6 +113,8 @@ fetch_files(int nfiles, char **urls) off_t current_bytes; off_t fsize; off_t total_bytes; + float file_perc; + float mainperc_file; char status[8]; struct url_stat ustat; char errormsg[PATH_MAX + 512]; @@ -137,16 +139,17 @@ fetch_files(int nfiles, char **urls) /* Try to stat all the files */ total_bytes = 0; for (i = 0; i < nfiles; i++) { - if (fetchStatURL(urls[i], &ustat, "") == 0 && ustat.size > 0) + if (fetchStatURL(urls[i], &ustat, "") == 0 && ustat.size > 0) { total_bytes += ustat.size; + } else { + total_bytes = 0; + break; + } } + mainperc_file = 100.0 / nfiles; current_bytes = 0; for (i = 0; i < nfiles; i++) { - last_progress = progress; - if (total_bytes == 0) - progress = (i*100)/nfiles; - fetchLastErrCode = 0; fetch_out = fetchXGetURL(urls[i], &ustat, ""); if (fetch_out == NULL) { @@ -156,6 +159,7 @@ fetch_files(int nfiles, char **urls) items[i*2 + 1] = "Failed"; dialog_msgbox("Fetch Error", errormsg, 0, 0, TRUE); + total_bytes = 0; continue; } @@ -170,6 +174,7 @@ fetch_files(int nfiles, char **urls) dialog_msgbox("Fetch Error", errormsg, 0, 0, TRUE); fclose(fetch_out); + total_bytes = 0; continue; } @@ -180,10 +185,15 @@ fetch_files(int nfiles, char **urls) current_bytes += chunk; fsize += chunk; - + + last_progress = progress; if (total_bytes > 0) { - last_progress = progress; - progress = (current_bytes*100)/total_bytes; + progress = (current_bytes*100)/total_bytes; + } else { + file_perc = ustat.size > 0 ? + (fsize*100)/ustat.size : 0; + progress = (i * mainperc_file) + + ((file_perc * mainperc_file) / 100); } if (ustat.size > 0) { @@ -200,7 +210,7 @@ fetch_files(int nfiles, char **urls) } if (ustat.size > 0 && fsize < ustat.size) { - if (fetchLastErrCode == 0) + if (fetchLastErrCode == 0) snprintf(errormsg, sizeof(errormsg), "Error while fetching %s: %s\n", urls[i], strerror(errno)); @@ -211,6 +221,7 @@ fetch_files(int nfiles, char **urls) items[i*2 + 1] = "Failed"; dialog_msgbox("Fetch Error", errormsg, 0, 0, TRUE); + total_bytes = 0; } else { items[i*2 + 1] = "Done"; nsuccess++; @@ -220,6 +231,10 @@ fetch_files(int nfiles, char **urls) fclose(file_out); } + dialog_mixedgauge("Fetching Distribution", + "Fetching distribution completed", 0, 0, progress, nfiles, + __DECONST(char **, items)); + free(items); return (nsuccess); }