Factor Studios commited on
Commit
e2dd4f4
·
verified ·
1 Parent(s): 750e393

Update vision_analyzer.py

Browse files
Files changed (1) hide show
  1. vision_analyzer.py +1 -56
vision_analyzer.py CHANGED
@@ -285,62 +285,7 @@ def get_rar_part_base(filename: str) -> str:
285
  return filename.split(".part")[0]
286
  return filename.replace(".rar", "")
287
 
288
- def extract_with_retry(rar_path: str, output_dir: str, max_retries: int = 2) -> bool:
289
- """Extract RAR with retry and recovery, handling multi-part archives"""
290
- filename = os.path.basename(rar_path)
291
-
292
- # For multi-part RARs, we need the first part
293
- if is_multipart_rar(filename):
294
- base_name = get_rar_part_base(filename)
295
- first_part = f"{base_name}.part01.rar"
296
- first_part_path = os.path.join(os.path.dirname(rar_path), first_part)
297
-
298
- if not os.path.exists(first_part_path):
299
- log_message(f"⚠️ Multi-part RAR detected but first part not found: {first_part}")
300
- return False
301
-
302
- rar_path = first_part_path
303
- log_message(f"📦 Processing multi-part RAR starting with: {first_part}")
304
-
305
- for attempt in range(max_retries):
306
- try:
307
- # Test RAR first
308
- test_cmd = ["unrar", "t", rar_path]
309
- test_result = subprocess.run(test_cmd, capture_output=True, text=True)
310
- if test_result.returncode != 0:
311
- log_message(f"⚠️ RAR test failed: {test_result.stderr}")
312
- if attempt == max_retries - 1:
313
- return False
314
- continue
315
-
316
- # Extract RAR
317
- cmd = ["unrar", "x", "-o+", rar_path, output_dir]
318
- if attempt > 0: # Try recovery on subsequent attempts
319
- cmd.insert(2, "-kb")
320
-
321
- result = subprocess.run(cmd, capture_output=True, text=True)
322
- if result.returncode == 0:
323
- log_message(f"✅ Successfully extracted: {os.path.basename(rar_path)}")
324
- return True
325
- else:
326
- error_msg = result.stderr or result.stdout
327
- log_message(f"⚠️ Extraction attempt {attempt + 1} failed: {error_msg}")
328
-
329
- if "checksum error" in error_msg.lower() or "CRC failed" in error_msg:
330
- log_message(f"⚠️ Data corruption detected, attempt {attempt + 1}")
331
- elif result.returncode == 10:
332
- log_message(f"⚠️ No files to extract (exit code 10)")
333
- return False
334
- elif result.returncode == 1:
335
- log_message(f"⚠️ Non-fatal error (exit code 1)")
336
-
337
- except Exception as e:
338
- log_message(f"❌ Extraction exception: {str(e)}")
339
- if attempt == max_retries - 1:
340
- return False
341
- time.sleep(1)
342
-
343
- return False
344
 
345
  def ensure_dir(path):
346
  os.makedirs(path, exist_ok=True)
 
285
  return filename.split(".part")[0]
286
  return filename.replace(".rar", "")
287
 
288
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
289
 
290
  def ensure_dir(path):
291
  os.makedirs(path, exist_ok=True)