yeq6x commited on
Commit
c02f846
·
1 Parent(s): 5708fc2

Add zero-length file check in _list_checkpoints function of app.py to skip empty files during checkpoint listing. This enhancement improves the robustness of file handling by preventing errors related to empty files.

Browse files
Files changed (1) hide show
  1. app.py +4 -0
app.py CHANGED
@@ -184,6 +184,10 @@ def _list_checkpoints(out_dir: str, limit: int = 20) -> List[str]:
184
  if fn.lower().endswith('.safetensors'):
185
  full = os.path.join(root, fn)
186
  try:
 
 
 
 
187
  items.append((os.path.getmtime(full), full))
188
  except Exception:
189
  pass
 
184
  if fn.lower().endswith('.safetensors'):
185
  full = os.path.join(root, fn)
186
  try:
187
+ # Skip files that are zero-length or currently being written
188
+ size = os.path.getsize(full)
189
+ if size <= 0:
190
+ continue
191
  items.append((os.path.getmtime(full), full))
192
  except Exception:
193
  pass