3
3
# Author: Lucio Torre <lucio.torre@canonical.com>
4
4
# Author: Natalia B. Bidart <natalia.bidart@canonical.com>
5
5
# Author: Guillermo Gonzalez <guillermo.gonzalez@canonical.com>
6
# Author: Facundo Batista <facundo@canonical.com>
7
8
# Copyright 2009-2011 Canonical Ltd.
277
278
def put_content(self, share, node, previous_hash, new_hash,
278
279
crc32, size, deflated_size, fd, upload_id=None,
280
upload_id_cb=None, magic_hash=None):
280
281
"""Put the content of fd into file node."""
281
282
req = self.put_content_request(share, node, previous_hash, new_hash,
282
283
crc32, size, deflated_size, fd,
283
284
upload_id=upload_id,
284
upload_id_cb=upload_id_cb)
285
upload_id_cb=upload_id_cb,
286
magic_hash=magic_hash)
285
287
return req.deferred
287
289
def put_content_request(self, share, node, previous_hash, new_hash,
288
290
crc32, size, deflated_size, fd, upload_id=None,
291
upload_id_cb=None, magic_hash=None):
290
292
"""Put the content of fd into file node, return the request."""
291
293
p = PutContent(self, share, node, previous_hash, new_hash,
292
294
crc32, size, deflated_size, fd,
293
295
upload_id=upload_id,
294
upload_id_cb=upload_id_cb)
296
upload_id_cb=upload_id_cb,
297
magic_hash=magic_hash)
1136
1139
@ivar new_generation: the generation that the volume is at now
1139
def __init__(self, protocol, share, node_id,
1140
previous_hash, new_hash, crc32, size,
1141
deflated_size, fd, upload_id=None, upload_id_cb=None):
1142
def __init__(self, protocol, share, node_id, previous_hash, new_hash,
1143
crc32, size, deflated_size, fd, upload_id=None,
1144
upload_id_cb=None, magic_hash=None):
1142
1145
"""Put content into a node.
1144
1147
@param protocol: the request handler
1150
1153
@param size: the size hint for the new content
1151
1154
@param fd: a file-like object to read data from
1152
1155
@param upload_id: the upload id (to resume the upload.)
1156
@param upload_id_cb: callback that will be called with the upload id
1157
assigned by the server for the session
1158
@param magic_hash: the magic_hash of the file
1155
1161
request.Request.__init__(self, protocol)
1178
1185
message.put_content.deflated_size = self.deflated_size
1179
1186
if self.upload_id:
1180
1187
message.put_content.upload_id = self.upload_id
1188
if self.magic_hash is not None:
1189
message.put_content.magic_hash = self.magic_hash
1181
1190
self.sendMessage(message)
1183
1192
def processMessage(self, message):