@@ -320,11 +320,12 @@ fn download_model_with_progress(model_path: &PathBuf) -> Result<(), Box<dyn std:
320320
321321 let start = Instant :: now ( ) ;
322322
323- // Use 40 minute timeout for large files
324- let response = match ureq:: get ( MODEL_URL )
325- . timeout ( Duration :: from_secs ( 2400 ) )
326- . call ( )
327- {
323+ // Use ureq with no timeout - we handle timeouts ourselves
324+ let agent = ureq:: AgentBuilder :: new ( )
325+ . timeout ( Duration :: from_secs ( 0 ) ) // Disable timeout - we read until EOF
326+ . build ( ) ;
327+
328+ let response = match agent. get ( MODEL_URL ) . call ( ) {
328329 Ok ( r) => r,
329330 Err ( e) => {
330331 spin_pb. finish_with_message ( format ! ( "❌ Connection failed: {}" , e) ) ;
@@ -363,14 +364,11 @@ fn download_model_with_progress(model_path: &PathBuf) -> Result<(), Box<dyn std:
363364 let mut buffer = vec ! [ 0u8 ; 65536 ] ;
364365 let mut downloaded: u64 = 0 ;
365366 let mut last_progress = Instant :: now ( ) ;
366- let mut consecutive_errors = 0 ;
367367
368368 loop {
369369 match reader. read ( & mut buffer) {
370370 Ok ( 0 ) => break , // EOF - download complete
371371 Ok ( n) => {
372- consecutive_errors = 0 ; // Reset error counter on successful read
373-
374372 if let Err ( e) = dest. write_all ( & buffer[ ..n] ) {
375373 pb. finish_with_message ( format ! ( "❌ Write error: {}" , e) ) ;
376374 return Err ( format ! ( "Write failed: {}" , e) . into ( ) ) ;
@@ -384,35 +382,19 @@ fn download_model_with_progress(model_path: &PathBuf) -> Result<(), Box<dyn std:
384382 last_progress = Instant :: now ( ) ;
385383 }
386384 }
387- Err ( e) if e. kind ( ) == std:: io:: ErrorKind :: TimedOut => {
388- consecutive_errors += 1 ;
389- if consecutive_errors >= 3 {
390- pb. finish_with_message ( format ! ( "❌ Download timed out after 3 retries" ) ) ;
391- return Err ( format ! ( "Download timed out" ) . into ( ) ) ;
392- }
393- // Continue reading on timeout - might be transient
394- continue ;
395- }
396385 Err ( e) if e. kind ( ) == std:: io:: ErrorKind :: UnexpectedEof => {
397- // Download completed but stream ended unexpectedly
398- // Check if we got all the data
386+ // Stream ended - check if we got all data
399387 if downloaded >= total_size {
400- break ; // We have all the data, consider it success
401- }
402- consecutive_errors += 1 ;
403- if consecutive_errors >= 3 {
404- pb. finish_with_message ( format ! ( "❌ Download incomplete: {}" , e) ) ;
405- return Err ( format ! ( "Download incomplete: {}" , e) . into ( ) ) ;
388+ break ; // Success!
406389 }
407- continue ;
390+ // Incomplete download
391+ pb. finish_with_message ( format ! ( "❌ Download incomplete" ) ) ;
392+ return Err ( format ! ( "Download incomplete: expected {}, got {}" , total_size, downloaded) . into ( ) ) ;
408393 }
409394 Err ( e) => {
410- consecutive_errors += 1 ;
411- if consecutive_errors >= 3 {
412- pb. finish_with_message ( format ! ( "❌ Download error: {}" , e) ) ;
413- return Err ( format ! ( "Download failed: {}" , e) . into ( ) ) ;
414- }
415- continue ;
395+ // Other errors - could be timeout, network issue, etc.
396+ pb. finish_with_message ( format ! ( "❌ Read error: {}" , e) ) ;
397+ return Err ( format ! ( "Read error: {}" , e) . into ( ) ) ;
416398 }
417399 }
418400 }
0 commit comments