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.

Remove incomplete Git checkouts after a failed download

Bowen Xue318f29a3a18d
diff --git a/freevideo_engine/comfy_source.py b/freevideo_engine/comfy_source.py
index f57fb01..74f9558 100644
--- a/freevideo_engine/comfy_source.py
+++ b/freevideo_engine/comfy_source.py
@@ -52,8 +52,7 @@ def download(target, *, plan, env, run):
if target.exists():
return network.clone(target, spec['url'], spec['commit'], network=plan, env=env, run=run)
stage = target.with_name(target.name + '.freevideo-download')
- # A finished checkout survives cancellation before publication. Git fetch's
- # own incomplete attempts are retained beside this directory by network.clone.
+ # A finished checkout survives cancellation before publication.
network.clone(stage, spec['url'], spec['commit'], network=plan, env=env, run=run)
if not all((stage / name).is_file() for name in ('main.py', 'folder_paths.py', 'requirements.txt')) or not (stage / 'comfy_api/latest').is_dir():
raise ValueError('The downloaded ComfyUI application is incomplete; files retained at ' + str(stage))
diff --git a/freevideo_engine/network.py b/freevideo_engine/network.py
index 4b69f81..b17120c 100644
--- a/freevideo_engine/network.py
+++ b/freevideo_engine/network.py
@@ -1399,6 +1399,12 @@ def clone(target, url, commit, *, sparse=None, run=None, network=None, env=None)
io_path(target.parent).mkdir(parents=True, exist_ok=True)
candidates = urls(dict(network, sources=dict(network.get('sources', {}), github=network.get('sources', {}).get('git', [{'id': 'official'}]))), 'github', url, env)
configured_env = env
+ # A depth-1 fetch cannot continue an earlier attempt, so what a past run left beside the target is only waste.
+ for stale in io_path(target.parent).glob(target.name + '.partial-*'):
+ try:
+ remove_tree(stale)
+ except OSError:
+ pass # Held by another program; the download goes on and a later run tries again.
for name, endpoint, route in [(name, endpoint, route) for name, endpoint in candidates
for route in route_order(network, 'git', name, configured_env)]:
env = route_environment(network, 'git', name, configured_env, route)
@@ -1446,6 +1452,12 @@ def clone(target, url, commit, *, sparse=None, run=None, network=None, env=None)
source_health(network, 'git', name, False)
event(network, category='git', source=name, route=route, file=target.name, action='fallback', reason='network-fetch-failed')
finally:
- if scratch and scratch.exists():
- remove_tree(scratch)
- raise RuntimeError('All Git sources failed. Check your network or connection mode in Downloads. Incomplete checkouts retained beside ' + str(target))
+ # Best effort: a file still held by antivirus or git.exe must not replace the
+ # error being handled or stop the fallback to the next source.
+ for leftover in (scratch, io_path(temporary)):
+ try:
+ if leftover and leftover.exists():
+ remove_tree(leftover)
+ except OSError:
+ pass
+ raise RuntimeError('All Git sources failed. Check your network or connection mode in Downloads.')