Skip to content

Commit

Permalink
Put folders first in diff/extract. Fixes #915. By @bastiencyr (#999)
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiencyr authored May 30, 2021
1 parent be6a39b commit 292066f
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 72 deletions.
4 changes: 3 additions & 1 deletion src/vorta/views/diff_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def __init__(self, fs_data, archive_newer, archive_older, json_lines):

files_with_attributes, nested_file_list = parse_diff_json_lines(lines) \
if json_lines else parse_diff_lines(lines)
# add type attributes : directory, files
files_with_attributes = [attrs + (type_f, ) for attrs, type_f in zip(files_with_attributes, fs_data[1])]
model = DiffTree(files_with_attributes, nested_file_list)

view = self.treeView
Expand Down Expand Up @@ -165,7 +167,7 @@ def parse_line(line):

files_with_attributes = [parse_line(line) for line in diff_lines if line]

return (files_with_attributes, nested_file_list)
return files_with_attributes, nested_file_list


def calc_size(significand, unit):
Expand Down
2 changes: 1 addition & 1 deletion src/vorta/views/extract_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def parse_json_line(data):
d = get_dict_from_list(nested_file_list, dirpath.split("/"))
if name not in d:
d[name] = {}
return size, modified, name, dirpath
return size, modified, name, dirpath, data["type"]

# handle case of a single line of result, which will already be a dict
lines = [fs_data] if isinstance(fs_data, dict) else \
Expand Down
2 changes: 1 addition & 1 deletion src/vorta/views/partials/tree_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def __init__(
parent=None,
):
files_with_attributes.sort(key=lambda x: x[2].upper()) # Sorts tuples by name ignoring case
files_with_attributes.sort(key=lambda x: x[0] != 0) # Pushes folders (size zero) to start of list
files_with_attributes.sort(key=lambda x: x[4] != 'd') # Pushes folders (type 'd') to start of list

super(TreeModel, self).__init__(parent)

Expand Down
Loading

0 comments on commit 292066f

Please sign in to comment.