diff --git a/lbrynet/core/LBRYcrdWallet.py b/lbrynet/core/LBRYcrdWallet.py index 5691d291f..8ec200611 100644 --- a/lbrynet/core/LBRYcrdWallet.py +++ b/lbrynet/core/LBRYcrdWallet.py @@ -530,8 +530,10 @@ class LBRYWallet(object): " sd_hash text)") def _save_name_metadata(self, name, sd_hash, txid): - d = self.db.runQuery("insert into name_metadata values (?, ?, ?)", - (name, txid, sd_hash)) + d = self.db.runQuery("select * from name_metadata where txid=?", (txid,)) + d.addCallback(lambda r: self.db.runQuery("insert into name_metadata values (?, ?, ?)", (name, txid, sd_hash)) + if not len(r) else None) + return d def _get_claim_metadata_for_sd_hash(self, sd_hash): diff --git a/lbrynet/lbryfilemanager/LBRYFileDownloader.py b/lbrynet/lbryfilemanager/LBRYFileDownloader.py index fa3ce530e..aad9d08ea 100644 --- a/lbrynet/lbryfilemanager/LBRYFileDownloader.py +++ b/lbrynet/lbryfilemanager/LBRYFileDownloader.py @@ -25,6 +25,8 @@ class ManagedLBRYFileDownloader(LBRYFileSaver): stream_info_manager, payment_rate_manager, wallet, download_directory, upload_allowed, file_name) self.sd_hash = None + self.txid = None + self.uri = None self.rowid = rowid self.lbry_file_manager = lbry_file_manager self.saving_status = False @@ -35,10 +37,19 @@ class ManagedLBRYFileDownloader(LBRYFileSaver): def _save_sd_hash(sd_hash): if len(sd_hash): self.sd_hash = sd_hash[0] + d = self.wallet._get_claim_metadata_for_sd_hash(self.sd_hash) + else: + d = defer.succeed(None) + + return d + + def _save_claim(name, txid): + self.uri = name + self.txid = txid return defer.succeed(None) d.addCallback(_save_sd_hash) - + d.addCallback(lambda r: _save_claim(r[0], r[1]) if r else None) d.addCallback(lambda _: self.lbry_file_manager.get_lbry_file_status(self)) def restore_status(status): diff --git a/lbrynet/lbrynet_daemon/LBRYDaemon.py b/lbrynet/lbrynet_daemon/LBRYDaemon.py index f16f5562a..9e92387d7 100644 --- a/lbrynet/lbrynet_daemon/LBRYDaemon.py +++ b/lbrynet/lbrynet_daemon/LBRYDaemon.py @@ -1101,6 +1101,7 @@ class LBRYDaemon(jsonrpc.JSONRPC): 'stream_name': f.stream_name, 'suggested_file_name': f.suggested_file_name, 'upload_allowed': f.upload_allowed, 'sd_hash': f.sd_hash, + 'lbry_uri': f.uri, 'txid': f.txid, 'total_bytes': size, 'written_bytes': written_bytes, 'code': status[0], 'message': message}) @@ -1109,7 +1110,8 @@ class LBRYDaemon(jsonrpc.JSONRPC): 'points_paid': f.points_paid, 'stopped': f.stopped, 'stream_hash': f.stream_hash, 'stream_name': f.stream_name, 'suggested_file_name': f.suggested_file_name, 'upload_allowed': f.upload_allowed, 'sd_hash': f.sd_hash, 'total_bytes': size, - 'written_bytes': written_bytes, 'code': status[0], 'message': status[1]}) + 'written_bytes': written_bytes, 'lbry_uri': f.uri, 'txid': f.txid, + 'code': status[0], 'message': status[1]}) return d