mirror of
				https://github.com/open-webui/open-webui
				synced 2025-06-26 18:26:48 +00:00 
			
		
		
		
	chore: remove unnecessary Path conversions
Remove unnecessary `pathlib.Path` conversions. (CACHE_DIR and DATA_DIR) Use `/` Path joining shorthand to ensure using platform specific Path separators (Windows: \\, Unix: /)
This commit is contained in:
		
							parent
							
								
									b94de4f002
								
							
						
					
					
						commit
						b15814c42f
					
				| @ -699,16 +699,16 @@ AZURE_STORAGE_KEY = os.environ.get("AZURE_STORAGE_KEY", None) | ||||
| # File Upload DIR | ||||
| #################################### | ||||
| 
 | ||||
| UPLOAD_DIR = f"{DATA_DIR}/uploads" | ||||
| Path(UPLOAD_DIR).mkdir(parents=True, exist_ok=True) | ||||
| UPLOAD_DIR = DATA_DIR / "uploads" | ||||
| UPLOAD_DIR.mkdir(parents=True, exist_ok=True) | ||||
| 
 | ||||
| 
 | ||||
| #################################### | ||||
| # Cache DIR | ||||
| #################################### | ||||
| 
 | ||||
| CACHE_DIR = f"{DATA_DIR}/cache" | ||||
| Path(CACHE_DIR).mkdir(parents=True, exist_ok=True) | ||||
| CACHE_DIR = DATA_DIR / "cache" | ||||
| CACHE_DIR.mkdir(parents=True, exist_ok=True) | ||||
| 
 | ||||
| 
 | ||||
| #################################### | ||||
|  | ||||
| @ -54,7 +54,7 @@ MAX_FILE_SIZE = MAX_FILE_SIZE_MB * 1024 * 1024  # Convert MB to bytes | ||||
| log = logging.getLogger(__name__) | ||||
| log.setLevel(SRC_LOG_LEVELS["AUDIO"]) | ||||
| 
 | ||||
| SPEECH_CACHE_DIR = Path(CACHE_DIR).joinpath("./audio/speech/") | ||||
| SPEECH_CACHE_DIR = CACHE_DIR / "audio" / "speech" | ||||
| SPEECH_CACHE_DIR.mkdir(parents=True, exist_ok=True) | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -74,7 +74,7 @@ async def create_new_function( | ||||
| 
 | ||||
|             function = Functions.insert_new_function(user.id, function_type, form_data) | ||||
| 
 | ||||
|             function_cache_dir = Path(CACHE_DIR) / "functions" / form_data.id | ||||
|             function_cache_dir = CACHE_DIR / "functions" / form_data.id | ||||
|             function_cache_dir.mkdir(parents=True, exist_ok=True) | ||||
| 
 | ||||
|             if function: | ||||
|  | ||||
| @ -25,7 +25,7 @@ from pydantic import BaseModel | ||||
| log = logging.getLogger(__name__) | ||||
| log.setLevel(SRC_LOG_LEVELS["IMAGES"]) | ||||
| 
 | ||||
| IMAGE_CACHE_DIR = Path(CACHE_DIR).joinpath("./image/generations/") | ||||
| IMAGE_CACHE_DIR = CACHE_DIR / "image" / "generations" | ||||
| IMAGE_CACHE_DIR.mkdir(parents=True, exist_ok=True) | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -192,7 +192,7 @@ async def speech(request: Request, user=Depends(get_verified_user)): | ||||
|         body = await request.body() | ||||
|         name = hashlib.sha256(body).hexdigest() | ||||
| 
 | ||||
|         SPEECH_CACHE_DIR = Path(CACHE_DIR).joinpath("./audio/speech/") | ||||
|         SPEECH_CACHE_DIR = CACHE_DIR / "audio" / "speech" | ||||
|         SPEECH_CACHE_DIR.mkdir(parents=True, exist_ok=True) | ||||
|         file_path = SPEECH_CACHE_DIR.joinpath(f"{name}.mp3") | ||||
|         file_body_path = SPEECH_CACHE_DIR.joinpath(f"{name}.json") | ||||
|  | ||||
| @ -105,7 +105,7 @@ async def create_new_tools( | ||||
|             specs = get_tools_specs(TOOLS[form_data.id]) | ||||
|             tools = Tools.insert_new_tool(user.id, form_data, specs) | ||||
| 
 | ||||
|             tool_cache_dir = Path(CACHE_DIR) / "tools" / form_data.id | ||||
|             tool_cache_dir = CACHE_DIR / "tools" / form_data.id | ||||
|             tool_cache_dir.mkdir(parents=True, exist_ok=True) | ||||
| 
 | ||||
|             if tools: | ||||
|  | ||||
| @ -110,7 +110,7 @@ class PDFGenerator: | ||||
|             # When running using `pip install -e .` the static directory is in the site packages. | ||||
|             # This path only works if `open-webui serve` is run from the root of this project. | ||||
|             if not FONTS_DIR.exists(): | ||||
|                 FONTS_DIR = Path("./backend/static/fonts") | ||||
|                 FONTS_DIR = Path(".") / "backend" / "static" / "fonts" | ||||
| 
 | ||||
|             pdf.add_font("NotoSans", "", f"{FONTS_DIR}/NotoSans-Regular.ttf") | ||||
|             pdf.add_font("NotoSans", "b", f"{FONTS_DIR}/NotoSans-Bold.ttf") | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user