236
237
return p.deferred
238
def get_content(self, share, node, hash, offset=0,
239
def get_content(self, share, node, a_hash, offset=0,
239
240
callback=None, node_attr_callback=None):
240
"""Get the content of node with hash
241
"""Get the content of node with 'a_hash'.
242
243
the content will be on request.content
243
244
or callback will be called for every piece that arrives.
246
req = self.get_content_request(share, node, hash, offset,
247
req = self.get_content_request(share, node, a_hash, offset,
247
248
callback, node_attr_callback)
248
249
return req.deferred
250
def get_content_request(self, share, node, hash, offset=0,
251
def get_content_request(self, share, node, a_hash, offset=0,
251
252
callback=None, node_attr_callback=None):
252
"""Get the content of node with hash, return the request.
253
"""Get the content of node with 'a_hash', return the request.
254
255
The content will be on request.content, or callback will be
255
256
called for every piece that arrives.
258
p = GetContent(self, share, node, hash, offset,
259
callback, node_attr_callback)
259
p = GetContent(self, share, node, a_hash, offset,
260
callback, node_attr_callback)
263
def put_content(self, share, node, previous_hash, hash,
264
def put_content(self, share, node, previous_hash, new_hash,
264
265
crc32, size, deflated_size, fd):
265
266
"""Put the content of fd into file node."""
266
req = self.put_content_request(share, node, previous_hash,
267
hash, crc32, size, deflated_size, fd)
267
req = self.put_content_request(share, node, previous_hash, new_hash,
268
crc32, size, deflated_size, fd)
268
269
return req.deferred
270
def put_content_request(self, share, node, previous_hash, hash,
271
def put_content_request(self, share, node, previous_hash, new_hash,
271
272
crc32, size, deflated_size, fd):
272
273
"""Put the content of fd into file node, return the request."""
273
p = PutContent(self, share, node, previous_hash, hash, crc32, size,
274
p = PutContent(self, share, node, previous_hash, new_hash,
275
crc32, size, deflated_size, fd)
278
279
def query(self, items):
279
"""Get the current hash for items if changed
280
"""Get the current hash for items if changed.
281
items is a list of (node, hash) tuples.
282
'items' is a list of (node, hash) tuples.
284
285
r = MultiQuery(self, items)
513
def __init__(self, protocol, share, node_id, hash,
514
def __init__(self, protocol, share, node_id, a_hash,
514
515
offset=0, callback=None, node_attr_callback=None):
515
"""Request the content of node with hash.
516
"""Request the content of node with 'a_hash'.
517
518
@param protocol: the request handler
518
519
@param share: the share node or root
519
520
@param node_id: the node id of the node we want to read
520
@param hash: the hash of the content of the version we have
521
@param a_hash: the hash of the content of the version we have
521
522
@param offset: offset for reading
522
523
@param callback: function to call when data arrives