From 324cbdcdb22d149325a7dff61ac8a4efa4d4beb7 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Fri, 10 May 2019 11:24:04 -0400 Subject: [PATCH 1/2] only save the content claim if stream_hash isn't None -stream_hash being none means we don't have the file in the database --- lbrynet/extras/daemon/Daemon.py | 3 ++- tests/integration/test_claim_commands.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lbrynet/extras/daemon/Daemon.py b/lbrynet/extras/daemon/Daemon.py index e87d4b2e9..44ecadbe2 100644 --- a/lbrynet/extras/daemon/Daemon.py +++ b/lbrynet/extras/daemon/Daemon.py @@ -2503,7 +2503,8 @@ class Daemon(metaclass=JSONRPCServerType): await self.storage.save_claims([self._old_get_temp_claim_info( tx, new_txo, claim_address, new_txo.claim, new_txo.claim_name, dewies_to_lbc(amount) )]) - await self.storage.save_content_claim(stream_hash, new_txo.id) + if stream_hash: + await self.storage.save_content_claim(stream_hash, new_txo.id) await self.analytics_manager.send_claim_action('publish') else: await account.ledger.release_tx(tx) diff --git a/tests/integration/test_claim_commands.py b/tests/integration/test_claim_commands.py index 3a0c7879c..534661e19 100644 --- a/tests/integration/test_claim_commands.py +++ b/tests/integration/test_claim_commands.py @@ -586,6 +586,10 @@ class StreamCommands(CommandTestCase): self.assertEqual(txs[0]['value'], '0.0') self.assertEqual(txs[0]['fee'], '-0.020107') await self.assertBalance(self.account, '7.479893') + self.assertEqual(1, len(self.daemon.jsonrpc_file_list())) + + await self.daemon.jsonrpc_file_delete(delete_all=True) + self.assertEqual(0, len(self.daemon.jsonrpc_file_list())) await self.stream_update(claim_id, bid='1.0') # updates previous claim txs = await self.out(self.daemon.jsonrpc_transaction_list()) From 1a182bc9bd38d92405427a5e1821d8dfc41261a4 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Fri, 10 May 2019 11:48:49 -0400 Subject: [PATCH 2/2] bytes/str --- lbrynet/extras/daemon/storage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lbrynet/extras/daemon/storage.py b/lbrynet/extras/daemon/storage.py index 9f55fa1ca..e68ba8af1 100644 --- a/lbrynet/extras/daemon/storage.py +++ b/lbrynet/extras/daemon/storage.py @@ -545,8 +545,8 @@ class SQLiteStorage(SQLiteMixin): "select stream_hash, download_directory, file_name from file where saved_file=1" ).fetchall(): if download_directory and file_name and os.path.isfile( - os.path.join(binascii.unhexlify(download_directory.encode()).decode(), - binascii.unhexlify(file_name.encode()).decode())): + os.path.join(binascii.unhexlify(download_directory).decode(), + binascii.unhexlify(file_name).decode())): continue else: removed.append((stream_hash,))