diff --git a/install.ps1 b/install.ps1 index 0f02b749..5609470d 100644 --- a/install.ps1 +++ b/install.ps1 @@ -8,7 +8,7 @@ param( $ErrorActionPreference = "Stop" $defaultInstallUrl = "https://raw.githubusercontent.com/Abdess/retrobios/main/install.py" -$defaultInstallSha256 = "2db3ce4cf58905d34d45633e7d955ba106b343f8348c8bd81ece5731560d331c" +$defaultInstallSha256 = "bc7e519f5bc6dbbc062a0ac29558dbe6862299e6d511b97c048f52ce2db5fba3" $maximumInstallerBytes = 2MB $installerExit = 0 $installer = if ($PSScriptRoot) { Join-Path $PSScriptRoot "install.py" } else { $null } diff --git a/install.py b/install.py index 35d5bc22..98f90ded 100644 --- a/install.py +++ b/install.py @@ -347,7 +347,9 @@ class Progress: def _draw(self) -> None: share = min(self.bytes / self.total_bytes, 1.0) elapsed = self.elapsed() - speed = self.bytes / elapsed if elapsed > 0 else 0 + # A resumed partial copy was on disk before the run started: counted + # in the share, never in the speed. + speed = self.transferred() / elapsed if elapsed > 0 else 0 left = (self.total_bytes - self.bytes) / speed if speed > 0 else 0 parts = [ f"{share * 100:5.1f}%", diff --git a/install.sh b/install.sh index a15a8ec1..8b2da94a 100755 --- a/install.sh +++ b/install.sh @@ -18,7 +18,7 @@ esac TEMP_INSTALLER="" TEMP_DIRECTORY="" DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/install.py" -DEFAULT_INSTALL_SHA256="2db3ce4cf58905d34d45633e7d955ba106b343f8348c8bd81ece5731560d331c" +DEFAULT_INSTALL_SHA256="bc7e519f5bc6dbbc062a0ac29558dbe6862299e6d511b97c048f52ce2db5fba3" MAX_INSTALLER_BYTES=2097152 cleanup() { diff --git a/tests/test_install.py b/tests/test_install.py index d7817856..43a09992 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -2782,6 +2782,32 @@ class TheProgressLineFitsTheTerminal(unittest.TestCase): +class AResumedCopyIsNotSpeed(unittest.TestCase): + """The live line divided every byte by the run's time, the 3 GB a + resumed partial copy already held included: 2.5 GB/s and 0:00 left on a + 1 MB/s link.""" + + def test_speed_counts_only_what_this_run_fetched(self): + import os as _os + + out = io.StringIO() + term = install.Terminal(out) + term.live = True + progress = install.Progress(1, 4_000_000_000, term) + progress.start -= 10 + progress.bytes = 3_000_000_000 + 10_000_000 + progress.resumed = 3_000_000_000 + with unittest.mock.patch.object( + install.shutil, "get_terminal_size", + return_value=_os.terminal_size((120, 24)), + ): + progress._draw() + line = out.getvalue() + self.assertIn(f"{install.format_size(1_000_000)}/s", line) + self.assertNotIn("0:00 left", line) + + + class ThePagesQuoteTheBootstrapsOwnWords(unittest.TestCase): """The installer page and the FAQ quoted "install.py SHA-256 mismatch", a message the bootstraps no longer print."""