Skip to content

Commit

Permalink
fix issue borgbase#940 - KeyError in get_dict_from_list
Browse files Browse the repository at this point in the history
- cause of error : defaultdict added more defaultdict while attempting to traverse the tree, but once a 'potential leaf' node was added, it was added as adict, not a defaultdict.
- two possible solutions:
    - 1 - change everywhere that adds a 'potential' leaf node to add a defaultdict (ie nested_dict()) - this occurs in several places, but not many.
    - 2 - change get_dict_from_list to add a default dict (not defaultdict) when traversing the tree, for the case where a multi-level node is added on top of an existing node. This requires only changing a single location, and means that the dictionaries returned by accessing the tree will behave like normal dict (ie, won't by default add missing keys).
  • Loading branch information
Robert Blenis committed Apr 12, 2021
1 parent 518df6f commit e3a358a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/vorta/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ def nested_dict():
- https://stackoverflow.com/a/16724937/3983708
- https://stackoverflow.com/a/14692747/3983708
"""
return defaultdict(nested_dict)
return dict()


def get_dict_from_list(dataDict, mapList):
return reduce(operator.getitem, mapList, dataDict)
return reduce(lambda d,k: d.setdefault(k,{}), mapList, dataDict)


def choose_file_dialog(parent, title, want_folder=True):
Expand Down

0 comments on commit e3a358a

Please sign in to comment.