1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2024-12-22 07:43:09 +00:00

Add support for special file types in borg diff output. By @real-yfprojects (#1265)

New item types were introduced to borg with borgbackup/borg#6624.
This commit is contained in:
yfprojects 2022-05-06 07:33:13 +00:00 committed by GitHub
parent b57414cfc2
commit de1ca052b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,8 +7,8 @@
from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import QHeaderView
from vorta.utils import (get_asset, get_dict_from_list, nested_dict, uses_dark_mode)
from vorta.utils import (get_asset, get_dict_from_list, nested_dict,
uses_dark_mode)
from vorta.views.partials.tree_view import TreeModel
uifile = get_asset('UI/diffresult.ui')
@ -48,7 +48,17 @@ def __init__(self, fs_data, archive_newer, archive_older, json_lines):
self.okButton.clicked.connect(self.accept)
SPECIAL_FILE_TYPES = ['directory', 'link', 'fifo', 'blkdev', 'chrdev']
def parse_diff_json_lines(diffs):
# helpers
valid_change_types = ['added', 'removed']
for file_type in SPECIAL_FILE_TYPES:
valid_change_types.append('added ' + file_type)
valid_change_types.append('removed ' + file_type)
# parsing
files_with_attributes = []
nested_file_list = nested_dict()
@ -88,8 +98,8 @@ def parse_diff_json_lines(diffs):
# pretty_bytes(-change['removed'], precision=1, sign=True))
change_type = 'modified'
change_type_priority = 3
elif change['type'] in ['added', 'removed', 'added link', 'removed link', 'changed link',
'added directory', 'removed directory']:
elif (change['type'] in valid_change_types
or change['type'] == 'changed link'):
if change['type'] in ['added directory', 'removed directory']:
file_type = 'd'
size = change.get('size', 0)
@ -125,7 +135,7 @@ def parse_line(line):
file_type = '-'
if line_split[0] in {'added', 'removed', 'changed'}:
change_type = line_split[0]
if line_split[1] in ['directory', 'link']:
if line_split[1] in SPECIAL_FILE_TYPES:
if line_split[1] in ['directory']:
file_type = 'd'
size = 0