|
@@ -1898,6 +1898,9 @@ class ArchiveFormatter(BaseFormatter):
|
|
|
|
|
|
|
|
|
class ItemFormatter(BaseFormatter):
|
|
|
+ # we provide the hash algos from python stdlib (except shake_*).
|
|
|
+ # shake_* is not provided because it uses an incompatible .digest() method to support variable length.
|
|
|
+ hash_algorithms = hashlib.algorithms_guaranteed.difference({'shake_128', 'shake_256'})
|
|
|
KEY_DESCRIPTIONS = {
|
|
|
'bpath': 'verbatim POSIX path, can contain any character except NUL',
|
|
|
'path': 'path interpreted as text (might be missing non-text characters, see bpath)',
|
|
@@ -1914,7 +1917,7 @@ class ItemFormatter(BaseFormatter):
|
|
|
('type', 'mode', 'uid', 'gid', 'user', 'group', 'path', 'bpath', 'source', 'linktarget', 'flags'),
|
|
|
('size', 'csize', 'dsize', 'dcsize', 'num_chunks', 'unique_chunks'),
|
|
|
('mtime', 'ctime', 'atime', 'isomtime', 'isoctime', 'isoatime'),
|
|
|
- tuple(sorted(hashlib.algorithms_guaranteed)),
|
|
|
+ tuple(sorted(hash_algorithms)),
|
|
|
('archiveid', 'archivename', 'extra'),
|
|
|
('health', )
|
|
|
)
|
|
@@ -1988,7 +1991,7 @@ class ItemFormatter(BaseFormatter):
|
|
|
'ctime': partial(self.format_time, 'ctime'),
|
|
|
'atime': partial(self.format_time, 'atime'),
|
|
|
}
|
|
|
- for hash_function in hashlib.algorithms_guaranteed:
|
|
|
+ for hash_function in self.hash_algorithms:
|
|
|
self.add_key(hash_function, partial(self.hash_item, hash_function))
|
|
|
self.used_call_keys = set(self.call_keys) & self.format_keys
|
|
|
|
|
@@ -2060,6 +2063,7 @@ class ItemFormatter(BaseFormatter):
|
|
|
return item.get_size(compressed=True)
|
|
|
|
|
|
def hash_item(self, hash_function, item):
|
|
|
+ assert hash_function in self.hash_algorithms
|
|
|
if 'chunks' not in item:
|
|
|
return ""
|
|
|
hash = hashlib.new(hash_function)
|