diff --git a/tubesync/sync/templates/sync/dashboard.html b/tubesync/sync/templates/sync/dashboard.html index 8c27684c..ccf4a6c3 100644 --- a/tubesync/sync/templates/sync/dashboard.html +++ b/tubesync/sync/templates/sync/dashboard.html @@ -125,7 +125,7 @@ Database - Database
{{ database_connection }} + Database
{{ database_connection }}{% if database_filesize %} {{ database_filesize|filesizeformat }}{% endif %} diff --git a/tubesync/sync/views.py b/tubesync/sync/views.py index dccf1820..43a51b91 100644 --- a/tubesync/sync/views.py +++ b/tubesync/sync/views.py @@ -14,7 +14,7 @@ from django.views.generic.detail import SingleObjectMixin from django.core.exceptions import SuspiciousFileOperation from django.http import HttpResponse from django.urls import reverse_lazy -from django.db import IntegrityError +from django.db import connection, IntegrityError from django.db.models import Q, Count, Sum, When, Case from django.forms import Form, ValidationError from django.utils.text import slugify @@ -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 + data['database_filesize'] = None + db_name = str(connection.get_connection_params()['database']) + db_path = pathlib.Path(db_name) if '/' == db_name[0] else None + if db_path and 'sqlite' == connection.vendor: + data['database_filesize'] = db_path.stat().st_size return data