From: Philipp Gesang Date: Tue, 2 May 2017 14:14:44 +0000 (+0200) Subject: clean up multi-index handling X-Git-Tag: v2.2~7^2~134 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=037994ca073a3cbb117b973782ca4fd8e67c2ac7;p=python-delta-tar clean up multi-index handling WIP --- diff --git a/deltatar/deltatar.py b/deltatar/deltatar.py index 71912b6..27c0630 100644 --- a/deltatar/deltatar.py +++ b/deltatar/deltatar.py @@ -1446,18 +1446,28 @@ class RestoreHelper(object): # tarfile.extractall for details. _directories = [] - def __init__(self, deltatar, cwd, index_list=[], backup_path=False, + def __init__(self, deltatar, cwd, index_list=None, backup_path=False, tarobj=None): ''' Constructor opens the tars and init the data structures. - Index list must be provided in reverse order (newer first) + Assumptions: + + - Index list must be provided in reverse order (newer first). + - “newer first” apparently means that if there are n backups + provided, the last full backup is at index n-1 and the most recent + diff backup is at index 0. + - Only the first, the second, and the last elements of + ``index_list`` are relevant, others will not be accessed. + - If no ``index_list`` is provided, both ``tarobj`` and + ``backup_path`` must be passed. + - If ``index_list`` is provided, the values of ``tarobj`` and + ``backup_path`` are ignored. ''' self._data = [] self._directories = [] self._deltatar = deltatar self._cwd = cwd - self._index_list = index_list try: import grp, pwd @@ -1469,9 +1479,9 @@ class RestoreHelper(object): else: self.canchown = False - if index_list: + if index_list is not None: for index in index_list: - is_full = (index == index_list[-1]) + is_full = index == index_list[-1] # make paths absolute to avoid cwd problems if not os.path.isabs(index): @@ -1551,6 +1561,10 @@ class RestoreHelper(object): Restore the path from the appropriate backup. Receives the current path from the newest (=first) index iterator. itpath must be not null. callback is a custom function that gets called for every file. + + NB: This function takes the attribute ``_data`` as input but will only + ever use its first and, if available, second element. Anything else in + ``._data[]`` will be ignored. ''' path = itpath['path']