diff --git a/backend/open_webui/__init__.py b/backend/open_webui/__init__.py index 6765c8f50..c6578c214 100644 --- a/backend/open_webui/__init__.py +++ b/backend/open_webui/__init__.py @@ -9,8 +9,6 @@ import uvicorn app = typer.Typer() KEY_FILE = Path.cwd() / ".webui_secret_key" -if (frontend_build_dir := Path(__file__).parent / "frontend").exists(): - os.environ["FRONTEND_BUILD_DIR"] = str(frontend_build_dir) @app.command() diff --git a/backend/open_webui/env.py b/backend/open_webui/env.py index 53745e7f3..b803b5863 100644 --- a/backend/open_webui/env.py +++ b/backend/open_webui/env.py @@ -188,14 +188,28 @@ WEBUI_BUILD_HASH = os.environ.get("WEBUI_BUILD_HASH", "dev-build") DATA_DIR = Path(os.getenv("DATA_DIR", BACKEND_DIR / "data")).resolve() if PIP_INSTALL: + NEW_DATA_DIR = Path(os.getenv("DATA_DIR", OPEN_WEBUI_DIR / "data")).resolve() + NEW_DATA_DIR.mkdir(parents=True, exist_ok=True) + # Check if the data directory exists in the package directory if DATA_DIR.exists(): - log.info(f"Moving {DATA_DIR} to {OPEN_WEBUI_DIR / 'data'}") - shutil.move(str(DATA_DIR), str(OPEN_WEBUI_DIR / "data")) + log.info(f"Moving {DATA_DIR} to {NEW_DATA_DIR}") + for item in DATA_DIR.iterdir(): + dest = NEW_DATA_DIR / item.name + if item.is_dir(): + shutil.copytree(item, dest, dirs_exist_ok=True) + else: + shutil.copy2(item, dest) + DATA_DIR = OPEN_WEBUI_DIR / "data" FRONTEND_BUILD_DIR = Path(os.getenv("FRONTEND_BUILD_DIR", BASE_DIR / "build")).resolve() +if PIP_INSTALL: + FRONTEND_BUILD_DIR = Path( + os.getenv("FRONTEND_BUILD_DIR", OPEN_WEBUI_DIR / "frontend") + ).resolve() + RESET_CONFIG_ON_START = ( os.environ.get("RESET_CONFIG_ON_START", "False").lower() == "true" diff --git a/package-lock.json b/package-lock.json index a11e69317..c24bde703 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "open-webui", - "version": "0.3.17.dev5", + "version": "0.3.17.dev6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "open-webui", - "version": "0.3.17.dev5", + "version": "0.3.17.dev6", "dependencies": { "@codemirror/lang-javascript": "^6.2.2", "@codemirror/lang-python": "^6.1.6", diff --git a/package.json b/package.json index ac45c9eda..e9e9b7ada 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "open-webui", - "version": "0.3.17.dev5", + "version": "0.3.17.dev6", "private": true, "scripts": { "dev": "npm run pyodide:fetch && vite dev --host",