Report db.sqlite3 size on dashboard

This commit is contained in:
tcely 2024-12-11 08:19:34 -05:00 committed by GitHub
parent 679f77b6b4
commit 3e5711f0f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -85,6 +85,12 @@ class DashboardView(TemplateView):
data['config_dir'] = str(settings.CONFIG_BASE_DIR)
data['downloads_dir'] = str(settings.DOWNLOAD_ROOT)
data['database_connection'] = settings.DATABASE_CONNECTION_STR
# Add the database filesize when using db.sqlite3
db_name = str(settings.DATABASES["default"]["NAME"])
db_path = pathlib.Path(db_name) if '/' == db_name[0] else None
if db_path and settings.DATABASE_CONNECTION_STR.startswith('sqlite at '):
db_size = db_path.stat().st_size
data['database_connection'] += f' ({db_size:,} bytes)'
return data