Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(downloads): a full disk is named before the transfer starts

David089f67bf76fd
diff --git a/src-tauri/src/commands/download.rs b/src-tauri/src/commands/download.rs
index 0bc7f3fd..9666713d 100644
--- a/src-tauri/src/commands/download.rs
+++ b/src-tauri/src/commands/download.rs
@@ -353,6 +353,50 @@ fn ended_early(total: u64, downloaded: u64) -> bool {
total > 0 && downloaded < total
}
+/// Headroom left free on the drive, on top of the bytes the download needs.
+/// Windows starts failing in ways that have nothing to do with us once the
+/// system drive runs dry, so the last gigabyte is never ours to take.
+const SPACE_RESERVE: u64 = 1024 * 1024 * 1024;
+
+/// Bytes still needed versus bytes still free, when the drive cannot hold the
+/// rest of this download. `None` means it fits, or that there is nothing to
+/// compare against: a server that declares no length gives no number to plan
+/// with, and a drive we cannot measure must not block the download.
+///
+/// Without this the transfer simply ran until the drive hit zero. On
+/// 2026-08-15 a 16.3 GB video model did exactly that on the test machine:
+/// curl died with a write error at 0 bytes free, the half file stayed behind,
+/// and the drive was too full for anything else to run. A model set is the one
+/// download big enough to fill a disk, so the check belongs here, where every
+/// download passes through, not in the caller that happens to know the sizes.
+fn space_shortfall(total: u64, already_on_disk: u64, available: Option<u64>) -> Option<(u64, u64)> {
+ let available = available?;
+ if total == 0 {
+ return None;
+ }
+ let needed = total.saturating_sub(already_on_disk).saturating_add(SPACE_RESERVE);
+ if available >= needed { None } else { Some((needed, available)) }
+}
+
+/// Free bytes on the drive that holds `dest`. The longest matching mount point
+/// wins, so a model folder on a mounted volume is measured against that volume
+/// and not against the root it hangs under.
+fn available_space_for(dest: &Path) -> Option<u64> {
+ let disks = sysinfo::Disks::new_with_refreshed_list();
+ disks
+ .iter()
+ .filter(|d| dest.starts_with(d.mount_point()))
+ .max_by_key(|d| d.mount_point().as_os_str().len())
+ .map(|d| d.available_space())
+}
+
+/// Gibibyte, weil Windows und der Finder den freien Platz so anzeigen und der
+/// Nutzer die Zahl aus der Meldung genau damit vergleicht. Der Katalog zaehlt
+/// aus demselben Grund in derselben Einheit.
+fn gib(bytes: u64) -> String {
+ format!("{:.1} GB", bytes as f64 / (1024.0 * 1024.0 * 1024.0))
+}
+
async fn do_download(
url: &str,
dest: &PathBuf,
@@ -413,6 +457,18 @@ async fn do_download(
content_length
};
+ // Stop before the first byte if the drive cannot hold the rest. Saying it
+ // now costs nothing; finding out at the end costs the whole transfer and
+ // leaves the machine with a full disk.
+ if let Some((needed, free)) = space_shortfall(total, already_on_disk, available_space_for(dest)) {
+ return Err(format!(
+ "Not enough free space for {}. It still needs {} and the drive has {} free. Free up some space and start it again, the part already downloaded is kept.",
+ dest.file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_else(|| "this download".to_string()),
+ gib(needed),
+ gib(free),
+ ));
+ }
+
// Update total size
if let Ok(mut dl) = downloads.lock() {
if let Some(p) = dl.get_mut(id) {
@@ -1001,6 +1057,36 @@ pub async fn check_model_sizes(
mod tests {
use super::*;
+ #[test]
+ fn a_full_drive_is_named_before_the_first_byte() {
+ // Der echte Fall vom 15.08.: 16,3 GB Videomodell, 15,2 GB frei.
+ let modell = 16_331_849_976;
+ let (needed, free) = space_shortfall(modell, 0, Some(15_200_000_000)).expect("muss knapp sein");
+ assert_eq!(free, 15_200_000_000);
+ assert!(needed > free);
+ // Genug Platz plus Reserve: der Download laeuft.
+ assert!(space_shortfall(modell, 0, Some(modell + SPACE_RESERVE)).is_none());
+ // Exakt die Reserve zu wenig: das ist der Fall, der Windows lahmlegt.
+ assert!(space_shortfall(modell, 0, Some(modell)).is_some());
+ }
+
+ #[test]
+ fn what_already_lies_on_disk_does_not_have_to_fit_twice() {
+ // Fortsetzung: 12 GB von 16,3 GB liegen schon, es fehlen 4,3 GB.
+ let total = 16_000_000_000;
+ assert!(space_shortfall(total, 12_000_000_000, Some(5_500_000_000)).is_none());
+ // Ohne Anrechnung des Vorhandenen waere derselbe Lauf abgelehnt worden.
+ assert!(space_shortfall(total, 0, Some(5_500_000_000)).is_some());
+ }
+
+ #[test]
+ fn without_a_number_nothing_is_blocked() {
+ // Server nennt keine Laenge: es gibt nichts zu rechnen, also kein Nein.
+ assert!(space_shortfall(0, 0, Some(1)).is_none());
+ // Laufwerk nicht messbar: ein unbekannter Wert darf niemanden aussperren.
+ assert!(space_shortfall(16_000_000_000, 0, None).is_none());
+ }
+
#[test]
fn a_short_body_is_never_renamed_into_place() {
assert!(ended_early(6_000_000_000, 3_500_000_000));
diff --git a/src/api/__tests__/bundle-size-drift.live.test.ts b/src/api/__tests__/bundle-size-drift.live.test.ts
new file mode 100644
index 00000000..f688a49d
--- /dev/null
+++ b/src/api/__tests__/bundle-size-drift.live.test.ts
@@ -0,0 +1,64 @@
+import { describe, it, expect } from 'vitest'
+import { getImageBundles, getVideoBundles } from '../discover'
+
+/**
+ * Waechter fuer die Groessenangaben der Buendel.
+ *
+ * Die Zahl neben einer Datei ist kein Schmuck. Nach ihr entscheidet der Nutzer,
+ * ob er den Download startet, und danach raeumt er vorher auf oder eben nicht.
+ * Am 15.08.2026 stand beim FramePack-Modell 13 GB, die Datei hat 16,3 GB. Auf
+ * der Testmaschine lief die Platte auf 0 Byte, der Rechner war danach nicht
+ * mehr benutzbar, und die halbe Datei blieb liegen.
+ *
+ * Der Lauf holt nur die Kopfzeilen, ein HEAD pro Datei, keine Nutzdaten. Er
+ * haengt am Netz und an HuggingFace, deshalb laeuft er nur mit `LIVE_SIZES=1`
+ * und nicht im normalen Gate, genau wie der Preis-Waechter der Cloud.
+ *
+ * LIVE_SIZES=1 npx vitest run src/api/__tests__/bundle-size-drift.live.test.ts
+ */
+const LIVE = process.env.LIVE_SIZES === '1'
+
+type Datei = { name: string; downloadUrl?: string; sizeGB?: number }
+
+const dateien = (): Datei[] => {
+ const alle: Datei[] = []
+ for (const b of [...getImageBundles(), ...getVideoBundles()]) {
+ for (const f of b.files ?? []) alle.push(f as Datei)
+ }
+ return alle
+}
+
+async function echteGroesse(url: string): Promise<number | null> {
+ const r = await fetch(url, { method: 'HEAD', redirect: 'follow' })
+ if (!r.ok) return null
+ const len = r.headers.get('content-length')
+ return len ? Number(len) : null
+}
+
+/**
+ * Der Katalog zaehlt in Gibibyte, also so, wie Windows und der Finder den
+ * freien Platz anzeigen. Genau damit vergleicht der Nutzer, und nur dann hilft
+ * ihm die Zahl. Ein Vergleich gegen die Dezimal-GB der Kopfzeile wuerde jeden
+ * Eintrag anmeckern und dabei die echten Faelle verstecken.
+ */
+const GIB = 1024 ** 3
+
+// Rundung auf eine Nachkommastelle plus etwas Luft. Was darunter liegt, ist
+// Anzeigegenauigkeit, kein Planungsfehler.
+const TOLERANZ_GIB = 0.15
+
+describe.runIf(LIVE)('Buendel-Groessen gegen die echten Dateien', () => {
+ it('keine Datei ist groesser als angekuendigt', { timeout: 180_000 }, async () => {
+ const zuKlein: string[] = []
+ for (const f of dateien()) {
+ if (!f.downloadUrl || f.sizeGB === undefined) continue
+ const echt = await echteGroesse(f.downloadUrl)
+ if (echt === null) continue
+ const echtGiB = echt / GIB
+ if (echtGiB > f.sizeGB + TOLERANZ_GIB) {
+ zuKlein.push(`${f.name}: angekuendigt ${f.sizeGB}, echt ${echtGiB.toFixed(2)}`)
+ }
+ }
+ expect(zuKlein, `Zu niedrig angegeben (GiB):\n${zuKlein.join('\n')}`).toEqual([])
+ })
+})
diff --git a/src/api/discover.ts b/src/api/discover.ts
index b9e44f70..b6d91070 100644
--- a/src/api/discover.ts
+++ b/src/api/discover.ts
@@ -1027,9 +1027,9 @@ export function getImageBundles(): ModelBundle[] {
{
name: 'T5-XXL Text Encoder (FP8)',
description: 'Required text encoder for FLUX prompt understanding.',
- pulls: '', tags: ['Text Encoder', '3.9 GB'], updated: '',
+ pulls: '', tags: ['Text Encoder', '4.6 GB'], updated: '',
downloadUrl: 'https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp8_e4m3fn.safetensors',
- filename: 't5xxl_fp8_e4m3fn.safetensors', subfolder: 'text_encoders', sizeGB: 3.9,
+ filename: 't5xxl_fp8_e4m3fn.safetensors', subfolder: 'text_encoders', sizeGB: 4.6,
},
{
name: 'CLIP-L Text Encoder',
@@ -1067,9 +1067,9 @@ export function getImageBundles(): ModelBundle[] {
{
name: 'T5-XXL Text Encoder (FP8)',
description: 'Required text encoder for FLUX prompt understanding.',
- pulls: '', tags: ['Text Encoder', '3.9 GB'], updated: '',
+ pulls: '', tags: ['Text Encoder', '4.6 GB'], updated: '',
downloadUrl: 'https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp8_e4m3fn.safetensors',
- filename: 't5xxl_fp8_e4m3fn.safetensors', subfolder: 'text_encoders', sizeGB: 3.9,
+ filename: 't5xxl_fp8_e4m3fn.safetensors', subfolder: 'text_encoders', sizeGB: 4.6,
},
{
name: 'CLIP-L Text Encoder',
@@ -1565,9 +1565,9 @@ export function getVideoBundles(): ModelBundle[] {
{
name: 'Qwen 2.5 VL 7B Text Encoder (FP8)',
description: 'Required text encoder for HunyuanVideo 1.5.',
- pulls: '', tags: ['Text Encoder', '7.5 GB'], updated: '',
+ pulls: '', tags: ['Text Encoder', '8.8 GB'], updated: '',
downloadUrl: 'https://huggingface.co/Comfy-Org/HunyuanVideo_1.5_repackaged/resolve/main/split_files/text_encoders/qwen_2.5_vl_7b_fp8_scaled.safetensors',
- filename: 'qwen_2.5_vl_7b_fp8_scaled.safetensors', subfolder: 'text_encoders', sizeGB: 7.5,
+ filename: 'qwen_2.5_vl_7b_fp8_scaled.safetensors', subfolder: 'text_encoders', sizeGB: 8.8,
},
{
name: 'CLIP-L Text Encoder',
@@ -1598,9 +1598,9 @@ export function getVideoBundles(): ModelBundle[] {
{
name: 'Gemma 3 12B Text Encoder (FP8)',
description: 'Required text encoder for LTX Video 2.x.',
- pulls: '', tags: ['Text Encoder', '~12 GB'], updated: 'New',
+ pulls: '', tags: ['Text Encoder', '12.4 GB'], updated: 'New',
downloadUrl: 'https://huggingface.co/Comfy-Org/ltx-2/resolve/main/split_files/text_encoders/gemma_3_12B_it_fp8_scaled.safetensors',
- filename: 'gemma_3_12B_it_fp8_scaled.safetensors', subfolder: 'text_encoders', sizeGB: 12,
+ filename: 'gemma_3_12B_it_fp8_scaled.safetensors', subfolder: 'text_encoders', sizeGB: 12.4,
},
],
},
@@ -1684,9 +1684,9 @@ export function getVideoBundles(): ModelBundle[] {
{
name: 'FramePack F1 I2V Model (FP8)',
description: 'Main I2V model · generates video from a single image.',
- pulls: '', tags: ['Model', '13 GB'], updated: '',
+ pulls: '', tags: ['Model', '15.3 GB'], updated: '',
downloadUrl: 'https://huggingface.co/Kijai/HunyuanVideo_comfy/resolve/main/FramePackI2V_HY_fp8_e4m3fn.safetensors',
- filename: 'FramePackI2V_HY_fp8_e4m3fn.safetensors', subfolder: 'diffusion_models', sizeGB: 13,
+ filename: 'FramePackI2V_HY_fp8_e4m3fn.safetensors', subfolder: 'diffusion_models', sizeGB: 15.3,
},
{
name: 'SigCLIP Vision Encoder',