forked from LBRYCommunity/lbry-sdk
Merge pull request #161 from lbryio/delete-lbry-file-without-claim
Delete lbry file with abandoned claim
This commit is contained in:
commit
c8bb0c0bc8
7 changed files with 38 additions and 11 deletions
|
@ -70,7 +70,7 @@ class DownloadManager(object):
|
||||||
|
|
||||||
def add_blob_to_list(blob, blob_num):
|
def add_blob_to_list(blob, blob_num):
|
||||||
self.blobs[blob_num] = blob
|
self.blobs[blob_num] = blob
|
||||||
log.info("Added blob (hash: %s, number %s) to the list", str(blob.blob_hash), str(blob_num))
|
log.debug("Added blob (hash: %s, number %s) to the list", str(blob.blob_hash), str(blob_num))
|
||||||
|
|
||||||
def error_during_add(err):
|
def error_during_add(err):
|
||||||
log.warning("An error occurred adding the blob to blobs. Error:%s", err.getErrorMessage())
|
log.warning("An error occurred adding the blob to blobs. Error:%s", err.getErrorMessage())
|
||||||
|
|
|
@ -86,6 +86,12 @@ def disable_noisy_loggers():
|
||||||
logging.getLogger('lbrynet.core.server.BlobAvailabilityHandler').setLevel(logging.INFO)
|
logging.getLogger('lbrynet.core.server.BlobAvailabilityHandler').setLevel(logging.INFO)
|
||||||
logging.getLogger('lbrynet.dht').setLevel(logging.INFO)
|
logging.getLogger('lbrynet.dht').setLevel(logging.INFO)
|
||||||
logging.getLogger('lbrynet.lbrynet_daemon.LBRYExchangeRateManager').setLevel(logging.INFO)
|
logging.getLogger('lbrynet.lbrynet_daemon.LBRYExchangeRateManager').setLevel(logging.INFO)
|
||||||
|
logging.getLogger('lbrynet.lbrynet_daemon.LBRYDaemon').setLevel(logging.INFO)
|
||||||
|
logging.getLogger('lbrynet.core.LBRYWallet').setLevel(logging.INFO)
|
||||||
|
logging.getLogger('lbrynet.lbryfile.LBRYFileMetadataManager').setLevel(logging.INFO)
|
||||||
|
logging.getLogger('lbrynet.core.client.DownloadManager').setLevel(logging.INFO)
|
||||||
|
logging.getLogger('lbrynet.lbryfilemanager.LBRYFileManager').setLevel(logging.INFO)
|
||||||
|
logging.getLogger('lbrynet.core.server.BlobRequestHandler').setLevel(logging.INFO)
|
||||||
|
|
||||||
|
|
||||||
@_log_decorator
|
@_log_decorator
|
||||||
|
|
|
@ -78,11 +78,11 @@ class BlobRequestHandler(object):
|
||||||
if read_handle is not None:
|
if read_handle is not None:
|
||||||
self.currently_uploading = blob
|
self.currently_uploading = blob
|
||||||
self.read_handle = read_handle
|
self.read_handle = read_handle
|
||||||
log.debug("Sending %s to client", str(blob))
|
log.info("Sending %s to client", str(blob))
|
||||||
response_fields['blob_hash'] = blob.blob_hash
|
response_fields['blob_hash'] = blob.blob_hash
|
||||||
response_fields['length'] = blob.length
|
response_fields['length'] = blob.length
|
||||||
return response
|
return response
|
||||||
log.debug("We can not send %s", str(blob))
|
log.warning("We can not send %s", str(blob))
|
||||||
response_fields['error'] = "BLOB_UNAVAILABLE"
|
response_fields['error'] = "BLOB_UNAVAILABLE"
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@ -132,13 +132,13 @@ class BlobRequestHandler(object):
|
||||||
|
|
||||||
def start_transfer():
|
def start_transfer():
|
||||||
self.file_sender = FileSender()
|
self.file_sender = FileSender()
|
||||||
log.info("Starting the file upload")
|
log.debug("Starting the file upload")
|
||||||
assert self.read_handle is not None, "self.read_handle was None when trying to start the transfer"
|
assert self.read_handle is not None, "self.read_handle was None when trying to start the transfer"
|
||||||
d = self.file_sender.beginFileTransfer(self.read_handle, consumer, count_bytes)
|
d = self.file_sender.beginFileTransfer(self.read_handle, consumer, count_bytes)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def set_expected_payment():
|
def set_expected_payment():
|
||||||
log.info("Setting expected payment")
|
log.debug("Setting expected payment")
|
||||||
if self.blob_bytes_uploaded != 0 and self.blob_data_payment_rate is not None:
|
if self.blob_bytes_uploaded != 0 and self.blob_data_payment_rate is not None:
|
||||||
# TODO: explain why 2**20
|
# TODO: explain why 2**20
|
||||||
self.wallet.add_expected_payment(self.peer,
|
self.wallet.add_expected_payment(self.peer,
|
||||||
|
|
|
@ -236,7 +236,7 @@ class DBLBRYFileMetadataManager(object):
|
||||||
|
|
||||||
@rerun_if_locked
|
@rerun_if_locked
|
||||||
def _get_sd_blob_hashes_for_stream(self, stream_hash):
|
def _get_sd_blob_hashes_for_stream(self, stream_hash):
|
||||||
log.info("Looking up sd blob hashes for stream hash %s", str(stream_hash))
|
log.debug("Looking up sd blob hashes for stream hash %s", str(stream_hash))
|
||||||
d = self.db_conn.runQuery("select sd_blob_hash from lbry_file_descriptors where stream_hash = ?",
|
d = self.db_conn.runQuery("select sd_blob_hash from lbry_file_descriptors where stream_hash = ?",
|
||||||
(stream_hash,))
|
(stream_hash,))
|
||||||
d.addCallback(lambda results: [r[0] for r in results])
|
d.addCallback(lambda results: [r[0] for r in results])
|
||||||
|
|
|
@ -10,6 +10,9 @@ from lbrynet.lbryfilemanager.LBRYFileStatusReport import LBRYFileStatusReport
|
||||||
from lbrynet.interfaces import IStreamDownloaderFactory
|
from lbrynet.interfaces import IStreamDownloaderFactory
|
||||||
from lbrynet.lbryfile.StreamDescriptor import save_sd_info
|
from lbrynet.lbryfile.StreamDescriptor import save_sd_info
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
import logging
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ManagedLBRYFileDownloader(LBRYFileSaver):
|
class ManagedLBRYFileDownloader(LBRYFileSaver):
|
||||||
|
@ -48,11 +51,16 @@ class ManagedLBRYFileDownloader(LBRYFileSaver):
|
||||||
self.claim_id = claim_id
|
self.claim_id = claim_id
|
||||||
return defer.succeed(None)
|
return defer.succeed(None)
|
||||||
|
|
||||||
|
def _notify_bad_claim(name, txid):
|
||||||
|
log.error("Error loading name claim for lbry file: lbry://%s, tx %s does not contain a valid claim", name, txid)
|
||||||
|
log.warning("lbry file for lbry://%s, tx %s has no claim, deleting it", name, txid)
|
||||||
|
return self.lbry_file_manager.delete_lbry_file(self)
|
||||||
|
|
||||||
def _save_claim(name, txid):
|
def _save_claim(name, txid):
|
||||||
self.uri = name
|
self.uri = name
|
||||||
self.txid = txid
|
self.txid = txid
|
||||||
d = self.wallet.get_claimid(name, txid)
|
d = self.wallet.get_claimid(name, txid)
|
||||||
d.addCallback(_save_claim_id)
|
d.addCallbacks(_save_claim_id, lambda err: _notify_bad_claim(name, txid))
|
||||||
return d
|
return d
|
||||||
|
|
||||||
d.addCallback(_save_sd_hash)
|
d.addCallback(_save_sd_hash)
|
||||||
|
|
|
@ -82,9 +82,9 @@ class LBRYFileManager(object):
|
||||||
|
|
||||||
def log_error(err, rowid, stream_hash, options):
|
def log_error(err, rowid, stream_hash, options):
|
||||||
log.error("An error occurred while starting a lbry file: %s", err.getErrorMessage())
|
log.error("An error occurred while starting a lbry file: %s", err.getErrorMessage())
|
||||||
log.error(rowid)
|
log.debug(rowid)
|
||||||
log.error(stream_hash)
|
log.debug(stream_hash)
|
||||||
log.error(options)
|
log.debug(options)
|
||||||
|
|
||||||
def start_lbry_files(lbry_files_and_options):
|
def start_lbry_files(lbry_files_and_options):
|
||||||
for rowid, stream_hash, options in lbry_files_and_options:
|
for rowid, stream_hash, options in lbry_files_and_options:
|
||||||
|
|
|
@ -2032,7 +2032,7 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||||
Args:
|
Args:
|
||||||
'txid': txid of claim, string
|
'txid': txid of claim, string
|
||||||
Return:
|
Return:
|
||||||
Confirmation message
|
txid
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if 'txid' in p.keys():
|
if 'txid' in p.keys():
|
||||||
|
@ -2051,6 +2051,19 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def jsonrpc_abandon_name(self, p):
|
||||||
|
"""
|
||||||
|
DEPRECIATED, use abandon_claim
|
||||||
|
|
||||||
|
Args:
|
||||||
|
'txid': txid of claim, string
|
||||||
|
Return:
|
||||||
|
txid
|
||||||
|
"""
|
||||||
|
|
||||||
|
return self.jsonrpc_abandon_claim(p)
|
||||||
|
|
||||||
|
|
||||||
def jsonrpc_support_claim(self, p):
|
def jsonrpc_support_claim(self, p):
|
||||||
"""
|
"""
|
||||||
Support a name claim
|
Support a name claim
|
||||||
|
|
Loading…
Reference in a new issue