Revision 29148653 snf-pithos-backend/pithos/backends/lib/hashfiler/blocker.py
b/snf-pithos-backend/pithos/backends/lib/hashfiler/blocker.py | ||
---|---|---|
31 | 31 |
# interpreted as representing official policies, either expressed |
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 |
from hashlib import new as newhasher |
|
35 |
from binascii import hexlify |
|
36 |
|
|
37 | 34 |
from fileblocker import FileBlocker |
38 | 35 |
|
36 |
|
|
39 | 37 |
def intersect(a, b): |
40 | 38 |
""" return the intersection of two lists """ |
41 | 39 |
return list(set(a) & set(b)) |
42 | 40 |
|
41 |
|
|
43 | 42 |
def union(a, b): |
44 | 43 |
""" return the union of two lists """ |
45 | 44 |
return list(set(a) | set(b)) |
... | ... | |
57 | 56 |
if params['blockpool']: |
58 | 57 |
from radosblocker import RadosBlocker |
59 | 58 |
self.rblocker = RadosBlocker(**params) |
60 |
except KeyError:
|
|
59 |
except KeyError:
|
|
61 | 60 |
pass |
62 | 61 |
|
63 | 62 |
self.fblocker = FileBlocker(**params) |
... | ... | |
93 | 92 |
(_, r_missing) = self.rblocker.block_stor(blocklist) |
94 | 93 |
return (hashes, union(r_missing, f_missing)) |
95 | 94 |
|
96 |
|
|
97 | 95 |
def block_delta(self, blkhash, offset, data): |
98 | 96 |
"""Construct and store a new block from a given block |
99 | 97 |
and a data 'patch' applied at offset. Return: |
... | ... | |
103 | 101 |
r_existed = True |
104 | 102 |
(f_hash, f_existed) = self.fblocker.block_delta(blkhash, offset, data) |
105 | 103 |
if self.rblocker: |
106 |
(r_hash, r_existed) = self.rblocker.block_delta(blkhash, offset, data) |
|
104 |
(r_hash, r_existed) = self.rblocker.block_delta(blkhash, offset, |
|
105 |
data) |
|
107 | 106 |
if not r_hash and not f_hash: |
108 | 107 |
return None, None |
109 | 108 |
if self.rblocker and not r_hash: |
Also available in: Unified diff