mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-20 18:59:07 -05:00
fix: a resumed download is not counted as speed
The live line divided every byte by the run's time, a partial copy left by an earlier run included, and showed a 3 GB resume as 2.5 GB/s with nothing left.
This commit is contained in:
1 parent
cf9406ab67
commit
9e8229c07a
4 files changed
+31
-3
No files matched your search
+1
-1
@@ -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 }
|
||||
|
||||
+3
-1
@@ -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}%",
|
||||
|
||||
+1
-1
@@ -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() {
|
||||
|
||||
@@ -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."""
|
||||
|
||||
Reference in new issue
Block a user