Merge pull request #5160 from vikrantrathore/main

fix: avoid overriding DATA_DIR and prevent errors when directories are the same
This commit is contained in:
Timothy Jaeryang Baek 2024-09-05 16:11:42 +02:00 committed by GitHub
commit fa786c8e05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -196,7 +196,7 @@ if PIP_INSTALL:
NEW_DATA_DIR.mkdir(parents=True, exist_ok=True)
# Check if the data directory exists in the package directory
if DATA_DIR.exists():
if DATA_DIR.exists() and DATA_DIR != NEW_DATA_DIR:
log.info(f"Moving {DATA_DIR} to {NEW_DATA_DIR}")
for item in DATA_DIR.iterdir():
dest = NEW_DATA_DIR / item.name
@ -205,10 +205,11 @@ if PIP_INSTALL:
else:
shutil.copy2(item, dest)
DATA_DIR = OPEN_WEBUI_DIR / "data"
DATA_DIR = Path(os.getenv("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")