Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0234.py @ 1626:63cef4dbf2a4
core, plugins file, XEP-0234, bridge: progression api enhancement:
- progressStarted have a new metadata parameter, useful to know the kind of progression, direction, etc. Check bridge doc
- progressGetAllMetadata can be used to retrieve this data and discover on currently running progressions
- progressFinished also have a new metadata parameter, used to e.g. indicate that hash is checked
- core: fixed progressGetAll
- file, XEP-0234: implemented the API modifications, hash is returned on progressFinished
- file: SatFile.checkSize allows to check size independently of close (be sure that all the data have been transfered though)
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 19 Nov 2015 18:13:26 +0100 |
parents | 4dd07d026214 |
children | 697effba0310 |
comparison
equal
deleted
inserted
replaced
1625:8b8b1af5905f | 1626:63cef4dbf2a4 |
---|---|
281 hasher = file_data['hash_hasher'] | 281 hasher = file_data['hash_hasher'] |
282 hash_ = hasher.hexdigest() | 282 hash_ = hasher.hexdigest() |
283 | 283 |
284 if hash_ == hash_given: | 284 if hash_ == hash_given: |
285 log.info(u"Hash checked, file was successfully transfered: {}".format(hash_)) | 285 log.info(u"Hash checked, file was successfully transfered: {}".format(hash_)) |
286 progress_metadata = {'hash': hash_, | |
287 'hash_algo': file_data['hash_algo'], | |
288 'hash_verified': C.BOOL_TRUE | |
289 } | |
290 error = None | |
286 else: | 291 else: |
287 log.warning(u"Hash mismatch, the file was not transfered correctly") | 292 log.warning(u"Hash mismatch, the file was not transfered correctly") |
293 progress_metadata=None | |
294 error = u"Hash mismatch: given={algo}:{given}, calculated={algo}:{our}".format( | |
295 algo = file_data['hash_algo'], | |
296 given = hash_given, | |
297 our = hash_) | |
288 | 298 |
289 self._j.delayedContentTerminate(session, content_name, profile=profile) | 299 self._j.delayedContentTerminate(session, content_name, profile=profile) |
290 content_data['file_obj'].close() | 300 content_data['file_obj'].close(progress_metadata, error) |
291 # we may have the last_try timer still active, so we try to cancel it | 301 # we may have the last_try timer still active, so we try to cancel it |
292 try: | 302 try: |
293 content_data['last_try_timer'].cancel() | 303 content_data['last_try_timer'].cancel() |
294 except (KeyError, internet_error.AlreadyCalled): | 304 except (KeyError, internet_error.AlreadyCalled): |
295 pass | 305 pass |