# if path is found in the first index as to be snapshotted, deal with it
# and finish
if path.startswith('snapshot://'):
- self.restore_file(itpath, data, path, l_no, self._deltatar.unprefixed(path))
+ self.restore_file(itpath, data, path, l_no, upath)
# now we restore parent_directory mtime
os.utime(parent_dir, (parent_dir_mtime, parent_dir_mtime))
# we go from index to index, finding the path in the index, then finding
# the index with the most recent snapshot of the file being restored
- cur_index = 1
- while cur_index < len(self._data):
- data = self._data[cur_index]
- d, l_no, dpath = self.find_path_in_index(data, upath)
- if not d:
- self._deltatar.logger.warn('Error restoring file %s from '
- 'index, not found in index %s' % (path, data['path']))
- return
-
- if d.get('path', '').startswith('delete://'):
- self._deltatar.logger.warn(('Strange thing happened, file '
- '%s was listed in first index but deleted by another '
- 'one. Path was ignored and untouched.') % path)
- return
- elif d.get('path', '').startswith('snapshot://'):
- self.restore_file(d, data, path, l_no, dpath)
-
- # now we restore parent_directory mtime
- os.utime(parent_dir, (parent_dir_mtime, parent_dir_mtime))
- return
- elif d.get('path', '').startswith('list://'):
- continue
+ if len(self._data) > 1:
+ data = self._data[1]
+ while True:
+ d, l_no, dpath = self.find_path_in_index(data, upath)
+ if not d:
+ self._deltatar.logger.warn('Error restoring file %s from '
+ 'index, not found in index %s' % (path, data['path']))
+ return
+
+ cur_path = d.get('path', '')
+ if cur_path.startswith('delete://'):
+ self._deltatar.logger.warn(('Strange thing happened, file '
+ '%s was listed in first index but deleted by another '
+ 'one. Path was ignored and untouched.') % path)
+ return
+ elif cur_path.startswith('snapshot://'):
+ self.restore_file(d, data, path, l_no, dpath)
+
+ # now we restore parent_directory mtime
+ os.utime(parent_dir, (parent_dir_mtime, parent_dir_mtime))
+ return
self._deltatar.logger.warn(('Error restoring file %s from index, '
'snapshot not found in any index') % path)
# NOTE: we restart the iterator sometimes because the iterator can be
# walked over completely multiple times, for example if one path if not
# found in one index and we have to go to the next index.
- if data['iterator'] is None:
+ it = data['iterator']
+ if it is None:
it = data['iterator'] = self._deltatar.iterate_index_path(data["path"])
d, l_no = it.__next__()
else:
- it = data['iterator']
d = data['last_itelement']
l_no = data['last_lno']
- dpath = self._deltatar.unprefixed(d.get('path', ''))
-
while True:
+ dpath = self._deltatar.unprefixed(d.get('path', ''))
if upath == dpath:
data['last_itelement'] = d
data['last_lno'] = l_no
data['last_itelement'] = d
data['last_lno'] = l_no
return None, 0, ''
- dpath = self._deltatar.unprefixed(d.get('path', ''))
def restore_directories_permissions(self):
'''