fix: SF3 download prefers SF2, cache invalidation on parse error
- Download endpoint reverses extension priority: .sf2 > .sf3 - loadSoundFont adds ?t= cache-buster, invalidates IndexedDB on error - Retry logic: delete corrupted cache entry, allow re-download
This commit is contained in:
@@ -131,18 +131,18 @@ async def download_soundfont_asset(sf_id: str):
|
||||
for base_dir in [UPLOAD_SF_DIR, SYSTEM_SF_DIR]:
|
||||
if not os.path.isdir(base_dir):
|
||||
continue
|
||||
for ext in [".sf3", ".sf2"]:
|
||||
for ext in [".sf2", ".sf3"]:
|
||||
for fname in os.listdir(base_dir):
|
||||
fbase, fext = os.path.splitext(fname)
|
||||
if fext.lower() == ext and fbase.lower() == clean_id.lower():
|
||||
full = os.path.join(base_dir, fname)
|
||||
return FileResponse(full, media_type="application/octet-stream", filename=f"{fbase}{ext}")
|
||||
return FileResponse(full, media_type="application/octet-stream", filename=f"soundfont{ext}")
|
||||
# Fallback: try exact match on sf_id
|
||||
for base_dir in [UPLOAD_SF_DIR, SYSTEM_SF_DIR]:
|
||||
for ext in [".sf3", ".sf2"]:
|
||||
for ext in [".sf2", ".sf3"]:
|
||||
full = os.path.join(base_dir, clean_id + ext)
|
||||
if os.path.exists(full):
|
||||
return FileResponse(full, media_type="application/octet-stream", filename=f"{clean_id}{ext}")
|
||||
return FileResponse(full, media_type="application/octet-stream", filename=f"soundfont{ext}")
|
||||
raise HTTPException(status_code=404, detail="SoundFont asset not found")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user