fix: keep tracked static files when the frontend is not built

Importing the config module in a source checkout without a frontend build deleted 17 tracked files from the backend static folder (favicons, logo, custom.css, loader.js, user.png and more). The cleanup that clears old static files ran every time, but the copy that refills the folder only runs when a frontend build exists. Anything that imports the backend without running the build first (pytest, a language server, running the backend alone) left a dirty git tree and a backend with no favicon, logo or default avatar.

The cleanup now only runs when a frontend build is present, so clearing and refilling happen together or not at all. Docker images, pip installs and dev setups that run the build first behave exactly as before.

Fixes #29968
This commit is contained in:
Classic298 2026-09-24 10:48:16 +02:00
parent bbfa876afd
commit 96458e58b6

View file

@ -98,7 +98,7 @@ async def import_legacy_config_json():
STATIC_DIR = Path(os.getenv('STATIC_DIR', OPEN_WEBUI_DIR / 'static')).resolve()
try:
if STATIC_DIR.exists():
if STATIC_DIR.exists() and (FRONTEND_BUILD_DIR / 'static').is_dir():
for item in STATIC_DIR.iterdir():
if item.is_file() or item.is_symlink():
try: