forked from open-webui/open-webui
		
	feat: show error toast if trying to download db on external db
This commit is contained in:
		
							parent
							
								
									e91a49c455
								
							
						
					
					
						commit
						47a33acfeb
					
				
					 4 changed files with 21 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
from fastapi import APIRouter, UploadFile, File, Response
 | 
			
		||||
from fastapi import Depends, HTTPException, status
 | 
			
		||||
from peewee import SqliteDatabase
 | 
			
		||||
from starlette.responses import StreamingResponse, FileResponse
 | 
			
		||||
from pydantic import BaseModel
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +8,7 @@ from pydantic import BaseModel
 | 
			
		|||
from fpdf import FPDF
 | 
			
		||||
import markdown
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
from apps.web.internal.db import DB
 | 
			
		||||
from utils.utils import get_admin_user
 | 
			
		||||
from utils.misc import calculate_sha256, get_gravatar_url
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -96,8 +97,13 @@ async def download_db(user=Depends(get_admin_user)):
 | 
			
		|||
            status_code=status.HTTP_401_UNAUTHORIZED,
 | 
			
		||||
            detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
 | 
			
		||||
        )
 | 
			
		||||
    if not isinstance(DB, SqliteDatabase):
 | 
			
		||||
        raise HTTPException(
 | 
			
		||||
            status_code=status.HTTP_400_BAD_REQUEST,
 | 
			
		||||
            detail=ERROR_MESSAGES.DB_NOT_SQLITE,
 | 
			
		||||
        )
 | 
			
		||||
    return FileResponse(
 | 
			
		||||
        f"{DATA_DIR}/webui.db",
 | 
			
		||||
        DB.database,
 | 
			
		||||
        media_type="application/octet-stream",
 | 
			
		||||
        filename="webui.db",
 | 
			
		||||
    )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue