Feature #2439 Add total size and file count display to source tab #2448
Feature #2439 Add total size and file count display to source tab #2448m3nu merged 3 commits intoborgbase:masterfrom
Conversation
m3nu
left a comment
There was a problem hiding this comment.
Thanks for the contribution — this is a nice quality-of-life feature. A few issues to address:
Bug: > 0 should be >= 0 for size/count checks
SourceFileModel.dir_size defaults to -1 (uncalculated sentinel). The current check if source.dir_size > 0 correctly skips uncalculated entries but also skips legitimate zero-byte directories/files. Should be >= 0. Same for dir_files_count.
Additionally, the display check if total_size > 0 has the same problem — if all sources are empty (0 bytes), the label stays blank even though there are valid calculated sources.
Nit: DB query could use Peewee aggregation
update_total_size() loads all SourceFileModel rows into Python and sums manually. A single aggregation query would be cleaner:
from peewee import fn
total_size, total_files = (
SourceFileModel
.select(fn.SUM(SourceFileModel.dir_size), fn.SUM(SourceFileModel.dir_files_count))
.where(SourceFileModel.profile == self.profile(), SourceFileModel.dir_size >= 0)
.scalar(as_tuple=True)
)
total_size = total_size or 0
total_files = total_files or 0Not blocking since the number of sources per profile is always small, but worth considering.
Nit: translation format string
"Total Size: {}, {} files" — positional {} placeholders make it harder for translators to reorder words for different languages. Named placeholders would be marginally better:
self.tr("Total Size: {size}, {count} files").format(size=pretty_bytes(total_size), count=total_files)|
Appreciate the review, |
|
Hiding sounds good. |
m3nu
left a comment
There was a problem hiding this comment.
All review items addressed. One optional style nit: from peewee import fn could be moved to the top-level imports instead of inside the method body, but not blocking.
LGTM, thanks for the quick turnaround.
src/vorta/views/source_tab.py
Outdated
| """ | ||
| Update the total size and files count for all sources. | ||
| """ | ||
| from peewee import fn |
There was a problem hiding this comment.
AI often puts imports inside functions. Something you need to look out for.
There was a problem hiding this comment.
I thought it was inside the function in the previous review, so I just put it there. But thanks for the advice
Description
Added a label to the source tab that displays the aggregate total size and file count
of all configured backup sources. The label updates automatically when sources are
added, removed, or recalculated.
Related Issue
Closes #2439
Motivation and Context
When a profile has multiple source directories, users had to manually calculate the
total size. This adds a simple summary label to make that information immediately visible.
How Has This Been Tested?
Screenshots
Types of changes
Checklist:
I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.