Mercurial > libervia-backend
diff 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 |
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0234.py Thu Nov 19 11:15:06 2015 +0100 +++ b/src/plugins/plugin_xep_0234.py Thu Nov 19 18:13:26 2015 +0100 @@ -283,11 +283,21 @@ if hash_ == hash_given: log.info(u"Hash checked, file was successfully transfered: {}".format(hash_)) + progress_metadata = {'hash': hash_, + 'hash_algo': file_data['hash_algo'], + 'hash_verified': C.BOOL_TRUE + } + error = None else: log.warning(u"Hash mismatch, the file was not transfered correctly") + progress_metadata=None + error = u"Hash mismatch: given={algo}:{given}, calculated={algo}:{our}".format( + algo = file_data['hash_algo'], + given = hash_given, + our = hash_) self._j.delayedContentTerminate(session, content_name, profile=profile) - content_data['file_obj'].close() + content_data['file_obj'].close(progress_metadata, error) # we may have the last_try timer still active, so we try to cancel it try: content_data['last_try_timer'].cancel()