mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-24 05:56:37 +00:00
Merge pull request #580 from tcely/patch-2
Report db.sqlite3 size on dashboard
This commit is contained in:
commit
3130ff2816
@ -125,7 +125,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr title="Database connection used by TubeSync">
|
<tr title="Database connection used by TubeSync">
|
||||||
<td class="hide-on-small-only">Database</td>
|
<td class="hide-on-small-only">Database</td>
|
||||||
<td><span class="hide-on-med-and-up">Database<br></span><strong>{{ database_connection }}</strong></td>
|
<td><span class="hide-on-med-and-up">Database<br></span><strong>{{ database_connection }}{% if database_filesize %} {{ database_filesize|filesizeformat }}{% endif %}</strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
@ -14,7 +14,7 @@ from django.views.generic.detail import SingleObjectMixin
|
|||||||
from django.core.exceptions import SuspiciousFileOperation
|
from django.core.exceptions import SuspiciousFileOperation
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.urls import reverse_lazy
|
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.db.models import Q, Count, Sum, When, Case
|
||||||
from django.forms import Form, ValidationError
|
from django.forms import Form, ValidationError
|
||||||
from django.utils.text import slugify
|
from django.utils.text import slugify
|
||||||
@ -85,6 +85,12 @@ class DashboardView(TemplateView):
|
|||||||
data['config_dir'] = str(settings.CONFIG_BASE_DIR)
|
data['config_dir'] = str(settings.CONFIG_BASE_DIR)
|
||||||
data['downloads_dir'] = str(settings.DOWNLOAD_ROOT)
|
data['downloads_dir'] = str(settings.DOWNLOAD_ROOT)
|
||||||
data['database_connection'] = settings.DATABASE_CONNECTION_STR
|
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
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user