Skip to content

Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.

Launcher updates use the signed mirror on every platform and leave a slow source

Bowen Xue98de7777457a
diff --git a/freevideo_engine/launcher_update.py b/freevideo_engine/launcher_update.py
index 9c8c8bc..337c5e1 100644
--- a/freevideo_engine/launcher_update.py
+++ b/freevideo_engine/launcher_update.py
@@ -36,6 +36,10 @@ MIRROR_BASE = 'https://modelscope.cn/models/BowenXue/FreeVideo-releases/resolve/
# ModelScope redirects large files to its regional CDN: cdn-lfs-cn-<n>.modelscope.cn.
MIRROR_CDN = re.compile(r'cdn-lfs-cn-[0-9]{1,2}\.modelscope\.cn')
UPDATE_STALL_SECONDS = 30
+# A source this slow for this long gives way to the next one, keeping the bytes
+# already fetched; if every source is slow, the fastest one finishes the file.
+UPDATE_SLOW_SECONDS = 15
+UPDATE_SLOW_BYTES_PER_SECOND = 256 * 1024
MANIFEST_CHECK_SECONDS = 20
_metadata_budget = threading.local()
log = logging.getLogger(__name__)
@@ -46,8 +50,9 @@ def mirror_url(relative):
def source_order(language=None):
- language = default_language() if language is None else language
- return ('mirror', 'github') if language.lower().startswith('zh') else ('github', 'mirror')
+ language = (default_language() if language is None else language).lower()
+ # Windows names its locales in words ('Chinese (Simplified)_China'), not 'zh_CN'.
+ return ('mirror', 'github') if language.startswith(('zh', 'chinese')) else ('github', 'mirror')
# The channel names the platform; launchers from before combined releases read
@@ -70,9 +75,10 @@ RELEASE_ASSETS = {CHANNEL: ('FreeVideo.exe', 'update-windows.json'),
LINUX_CHANNEL: ('FreeVideo-Linux-x86_64.AppImage', 'update-linux.json')}
CHANNELS = tuple(RELEASE_ASSETS)
MANIFEST_DOMAIN = b'FreeVideo update manifest v1\x00'
-# The mirror is only a source for packages whose own signature the launcher can
-# check after download; DMG and AppImage have none, so they stay on GitHub.
-MIRROR_CHANNELS = (CHANNEL,)
+# Every platform's mirror manifest carries the release signature, which binds the
+# package digest; the Windows launcher also checks a mirror-only download's
+# Authenticode signature, and a Mac DMG is checked with codesign before use.
+MIRROR_CHANNELS = CHANNELS
RETRY_SECONDS = 60
MAX_RETRY_SECONDS = 15 * 60
MAX_DOWNLOAD_RETRIES = 3
@@ -661,7 +667,8 @@ def download(candidate, root, token='', *, progress=None, cancel=None, language=
try:
network.download(download_sources(candidate, language), io_path(target), asset['sha256'], report,
network=dict(quiet=True, resource_check=cancelled), size=asset['bytes'],
- stall_seconds=UPDATE_STALL_SECONDS, low_speed_limit=0, cycles=1,
+ stall_seconds=UPDATE_STALL_SECONDS, slow_seconds=UPDATE_SLOW_SECONDS,
+ low_speed_limit=UPDATE_SLOW_BYTES_PER_SECOND, cycles=2,
category='launcher-update', validate_url=_trusted_url, verify=verify_signature,
fallbacks=download_fallbacks(candidate, token))
except network.DownloadError as error:
diff --git a/freevideo_engine/network.py b/freevideo_engine/network.py
index 79131f5..e50fe9b 100644
--- a/freevideo_engine/network.py
+++ b/freevideo_engine/network.py
@@ -975,10 +975,15 @@ def download_here(candidates, path, expected, progress=None, *, network=None, en
reject(partial, 'hash-rejected')
timeout = network.get('timeout_seconds', 5)
affinity = partial.with_name(partial.name + '.source.json')
- candidates = [(name, address, route, headers) for name, url in candidates
- for address, headers in ([(url, ())] +
+ candidates = [(name, address, route, headers, fallback) for name, url in candidates
+ for fallback, (address, headers) in enumerate([(url, ())] +
([(fallbacks[name][0], tuple(fallbacks[name][1]))] if fallbacks and name in fallbacks else []))
for route in route_order(network, category, name, env)]
+ if updating:
+ # Every source's own address comes before any alternate address, so a
+ # slow source is left after one attempt rather than one per address.
+ candidates.sort(key=lambda row: row[4])
+ candidates = [row[:4] for row in candidates]
if not candidates:
raise RuntimeError('No download sources configured; existing files retained')
if model and not network.get('manual_source_switch') and partial.exists() and affinity.is_file():
@@ -994,6 +999,8 @@ def download_here(candidates, path, expected, progress=None, *, network=None, en
for cycle in range(cycles):
# Once every route has been tried, keep the fastest observed route even
# if the user's entire connection is slow. Do not oscillate forever.
+ if cycle and updating and not any(measured_rates.values()):
+ break # No source was left for being slow, so none is worth resuming.
if cycle and measured_rates:
candidates.sort(key=lambda row: -measured_rates.get((row[0], row[2]), 0))
for candidate_index, (name, original_url, route, extra_headers) in enumerate(candidates):
@@ -1144,8 +1151,10 @@ def download_here(candidates, path, expected, progress=None, *, network=None, en
continue
current_size = partial.stat().st_size if partial.exists() else 0
if slow_seconds is not None:
- measured_rates[name, route] = (max(0, current_size - offset) /
- max(.001, time.monotonic() - started)) if slow else 0
+ # A later failure at another address of the same source and
+ # route must not erase the rate it was measured at.
+ measured_rates[name, route] = max(measured_rates.get((name, route), 0), (
+ max(0, current_size - offset) / max(.001, time.monotonic() - started)) if slow else 0)
if faster is not None:
measured_rates[name, route] = compare['current']
measured_rates.update(compare['rates'])