reject model migration to subdirectory of source cache

This commit is contained in:
James Pine
2026-03-16 03:43:37 -07:00
parent 8906bee23e
commit e9f63d6c57
+3
View File
@@ -132,6 +132,9 @@ async def migrate_models(request: models.ModelMigrateRequest):
if source.resolve() == destination.resolve():
raise HTTPException(status_code=400, detail="Source and destination are the same directory")
if destination.resolve().is_relative_to(source.resolve()):
raise HTTPException(status_code=400, detail="Destination cannot be inside the current cache directory")
model_dirs = [d for d in source.iterdir() if d.name.startswith("models--") and d.is_dir()]
if not model_dirs:
return {"moved": 0, "errors": [], "source": str(source), "destination": str(destination)}