return tarobj.next ()
+def idxent_of_tarinfo (tarinfo):
+ """
+ Scrape the information relevant for the index from a *TarInfo* object.
+ Keys like the inode number that lack a corresponding field in a TarInfo
+ will be set to some neutral value.
+ Example output:
+
+ { "inode" : 0
+ , "uid" : 0
+ , "path" : "snapshot://annotations.db"
+ , "offset" : 0
+ , "volume" : 0
+ , "mode" : 33152
+ , "ctime" : 1502798115
+ , "mtime" : 1502196423
+ , "size" : 144
+ , "type" : "file"
+ , "gid" : 0
+ }
+
+ """
+
+ return \
+ { "inode" : 0 # ignored when reading the index
+ , "uid" : tarinfo.uid
+ , "gid" : tarinfo.gid
+ , "path" : tarinfo.name # keeping URI scheme
+ , "offset" : 0 # to be added by the caller
+ , "volume" : tarinfo.volume_offset
+ , "mode" : tarinfo.mode
+ , "ctime" : tarinfo.mtime
+ , "mtime" : tarinfo.mtime
+ , "size" : tarinfo.size
+ , "type" : tarinfo.type
+ }
+
+
def gen_rescue_index (backup_tar_path, mode, password=None, key=None):
psidx = [] # pseudo index, return value
offsets = None
if secret is not None:
offsets = crypto.reconstruct_offsets (backup_tar_path, secret)
fileobj = bltn_open (backup_tar_path, "rb")
- psinfos = [ read_tarobj_at_offset (fileobj, off, mode, secret=secret)
+ infos = [ (off, read_tarobj_at_offset (fileobj, off, mode, secret=secret))
for off in offsets ]
+ def aux (o, ti):
+ ie = idxent_of_tarinfo (ti)
+ ie ["offset"] = o
+ return ie
+ psidx = [ aux (o, ti) for o, ti in infos ]
return psidx