updating stream claim with new file now correctly updates file list removing old file
This commit is contained in:
parent
0a1e97fe23
commit
8f96b07559
2 changed files with 30 additions and 1 deletions
|
@ -2498,13 +2498,17 @@ class Daemon(metaclass=JSONRPCServerType):
|
|||
new_txo = tx.outputs[0]
|
||||
|
||||
if not preview:
|
||||
old_stream_hash = await self.storage.get_stream_hash_for_sd_hash(old_txo.claim.stream.source.sd_hash)
|
||||
if file_path is not None:
|
||||
if old_stream_hash:
|
||||
stream_to_delete = self.stream_manager.get_stream_by_stream_hash(old_stream_hash)
|
||||
await self.stream_manager.delete_stream(stream_to_delete, delete_file=False)
|
||||
file_stream = await self.stream_manager.create_stream(file_path)
|
||||
new_txo.claim.stream.source.sd_hash = file_stream.sd_hash
|
||||
new_txo.script.generate()
|
||||
stream_hash = file_stream.stream_hash
|
||||
else:
|
||||
stream_hash = await self.storage.get_stream_hash_for_sd_hash(old_txo.claim.stream.source.sd_hash)
|
||||
stream_hash = old_stream_hash
|
||||
if channel:
|
||||
new_txo.sign(channel)
|
||||
await tx.sign([account])
|
||||
|
|
|
@ -269,6 +269,31 @@ class StreamCommands(CommandTestCase):
|
|||
'hovercraft3', channel_id=baz_id, channel_account_id=[account1_id]
|
||||
)
|
||||
|
||||
async def test_publish_updates_file_list(self):
|
||||
tx = await self.out(self.stream_create(title='created'))
|
||||
txo = tx['outputs'][0]
|
||||
claim_id, expected = txo['claim_id'], txo['value']
|
||||
files = self.sout(self.daemon.jsonrpc_file_list())
|
||||
self.assertEqual(1, len(files))
|
||||
self.assertEqual(tx['txid'], files[0]['txid'])
|
||||
self.assertEqual(expected, files[0]['metadata'])
|
||||
|
||||
# update with metadata-only changes
|
||||
tx = await self.out(self.stream_update(claim_id, title='update 1'))
|
||||
files = self.sout(self.daemon.jsonrpc_file_list())
|
||||
expected['title'] = 'update 1'
|
||||
self.assertEqual(1, len(files))
|
||||
self.assertEqual(tx['txid'], files[0]['txid'])
|
||||
self.assertEqual(expected, files[0]['metadata'])
|
||||
|
||||
# update with new data
|
||||
tx = await self.out(self.stream_update(claim_id, title='update 2', data=b'updated data'))
|
||||
expected = tx['outputs'][0]['value']
|
||||
files = self.sout(self.daemon.jsonrpc_file_list())
|
||||
self.assertEqual(1, len(files))
|
||||
self.assertEqual(tx['txid'], files[0]['txid'])
|
||||
self.assertEqual(expected, files[0]['metadata'])
|
||||
|
||||
async def test_setting_stream_fields(self):
|
||||
values = {
|
||||
'title': "Cool Content",
|
||||
|
|
Loading…
Add table
Reference in a new issue