From 3357a419ab482eb4b5105fae6201d56a0e90bafa Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Mon, 22 Apr 2019 15:24:51 -0400 Subject: [PATCH] ability to overide the file name, hash and size when updating a stream claim --- lbrynet/extras/daemon/Daemon.py | 4 ++++ lbrynet/schema/claim.py | 6 ++++++ tests/integration/test_claim_commands.py | 9 +++++++++ 3 files changed, 19 insertions(+) diff --git a/lbrynet/extras/daemon/Daemon.py b/lbrynet/extras/daemon/Daemon.py index c9e050936..e8e65d041 100644 --- a/lbrynet/extras/daemon/Daemon.py +++ b/lbrynet/extras/daemon/Daemon.py @@ -2231,6 +2231,7 @@ class Daemon(metaclass=JSONRPCServerType): Usage: stream_update ( | --claim_id=) [--bid=] [--file_path=] + [--file_name=] [--file_size=] [--file_hash=] [--tags=...] [--clear_tags] [--languages=...] [--clear_languages] [--locations=...] [--clear_locations] @@ -2246,6 +2247,9 @@ class Daemon(metaclass=JSONRPCServerType): --claim_id= : (str) id of the stream claim to update --bid= : (decimal) amount to back the claim --file_path= : (str) path to file to be associated with name. + --file_name= : (str) override file name, defaults to name from file_path. + --file_size= : (str) override file size, otherwise automatically computed. + --file_hash= : (str) override file hash, otherwise automatically computed. --fee_currency= : (string) specify fee currency --fee_amount= : (decimal) content download fee --fee_address= : (str) address where to send fee payments, will use diff --git a/lbrynet/schema/claim.py b/lbrynet/schema/claim.py index 56580e7a6..9fe2ed40e 100644 --- a/lbrynet/schema/claim.py +++ b/lbrynet/schema/claim.py @@ -212,6 +212,12 @@ class Stream(BaseClaim): if 'sd_hash' in kwargs: self.source.sd_hash = kwargs.pop('sd_hash') + if 'file_size' in kwargs: + self.source.size = kwargs.pop('file_size') + if 'file_name' in kwargs: + self.source.name = kwargs.pop('file_name') + if 'file_hash' in kwargs: + self.source.file_hash = kwargs.pop('file_hash') stream_type = None if file_path is not None: diff --git a/tests/integration/test_claim_commands.py b/tests/integration/test_claim_commands.py index becfe0834..2224d8706 100644 --- a/tests/integration/test_claim_commands.py +++ b/tests/integration/test_claim_commands.py @@ -358,6 +358,15 @@ class StreamCommands(CommandTestCase): fixed_values['locations'] = [{'country': 'BR'}] self.assertEqual(txo['value'], fixed_values) + # modifying hash/size/name + fixed_values['source']['name'] = 'changed_name' + fixed_values['source']['hash'] = 'cafebeef' + fixed_values['source']['size'] = '42' + tx = await self.out(self.stream_update( + claim_id, file_name='changed_name', file_hash='cafebeef', file_size=42 + )) + self.assertEqual(tx['outputs'][0]['value'], fixed_values) + # send claim to someone else new_account = await self.out(self.daemon.jsonrpc_account_create('second account')) account2_id, account2 = new_account['id'], self.daemon.get_account_or_error(new_account['id'])