Correctly sort archives by size. By @samuel-w (#729)

This commit is contained in:
Samuel 2020-11-28 18:51:24 -06:00 committed by GitHub
parent 0b6961213f
commit fc2b70db64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -20,6 +20,7 @@ from vorta.i18n import trans_late
from vorta.models import ArchiveModel, BackupProfileMixin from vorta.models import ArchiveModel, BackupProfileMixin
from vorta.utils import (choose_file_dialog, format_archive_name, get_asset, from vorta.utils import (choose_file_dialog, format_archive_name, get_asset,
get_mount_points, pretty_bytes) get_mount_points, pretty_bytes)
from vorta.views.source_tab import SizeItem
from vorta.views.diff_dialog import DiffDialog from vorta.views.diff_dialog import DiffDialog
from vorta.views.diff_result import DiffResult from vorta.views.diff_result import DiffResult
from vorta.views.extract_dialog import ExtractDialog from vorta.views.extract_dialog import ExtractDialog
@ -115,7 +116,7 @@ class ArchiveTab(ArchiveTabBase, ArchiveTabUI, BackupProfileMixin):
formatted_time = archive.time.strftime('%Y-%m-%d %H:%M') formatted_time = archive.time.strftime('%Y-%m-%d %H:%M')
self.archiveTable.setItem(row, 0, QTableWidgetItem(formatted_time)) self.archiveTable.setItem(row, 0, QTableWidgetItem(formatted_time))
self.archiveTable.setItem(row, 1, QTableWidgetItem(pretty_bytes(archive.size))) self.archiveTable.setItem(row, 1, SizeItem(pretty_bytes(archive.size)))
if archive.duration is not None: if archive.duration is not None:
formatted_duration = str(timedelta(seconds=round(archive.duration))) formatted_duration = str(timedelta(seconds=round(archive.duration)))
else: else:

View File

@ -19,6 +19,11 @@ class SourceColumn:
class SizeItem(QTableWidgetItem): class SizeItem(QTableWidgetItem):
def __lt__(self, other): def __lt__(self, other):
if other.text() == '':
return False
elif self.text() == '':
return True
else:
return sort_sizes([self.text(), other.text()]) == [self.text(), other.text()] return sort_sizes([self.text(), other.text()]) == [self.text(), other.text()]