removing claim information from files related API commands

This commit is contained in:
Kay Kurokawa 2017-11-02 15:36:00 -04:00 committed by Jack Robison
parent 456c94b3cb
commit 971c720642
No known key found for this signature in database
GPG key ID: 284699E7404E3CFF
2 changed files with 6 additions and 75 deletions

View file

@ -112,12 +112,9 @@ class Checker(object):
class _FileID(IterableContainer):
"""The different ways a file can be identified"""
NAME = 'name'
SD_HASH = 'sd_hash'
FILE_NAME = 'file_name'
STREAM_HASH = 'stream_hash'
CLAIM_ID = "claim_id"
OUTPOINT = "outpoint"
ROWID = "rowid"
@ -880,32 +877,6 @@ class Daemon(AuthJSONRPCServer):
size = None
message = None
claim = yield self.session.wallet.get_claim_by_claim_id(lbry_file.claim_id,
check_expire=False)
if claim and 'value' in claim:
metadata = claim['value']
else:
metadata = None
if claim and 'channel_name' in claim:
channel_name = claim['channel_name']
else:
channel_name = None
if lbry_file.txid and lbry_file.nout is not None:
outpoint = repr(ClaimOutpoint(lbry_file.txid, lbry_file.nout))
else:
outpoint = None
if claim and 'has_signature' in claim:
has_signature = claim['has_signature']
else:
has_signature = None
if claim and 'signature_is_valid' in claim:
signature_is_valid = claim['signature_is_valid']
else:
signature_is_valid = None
result = {
'completed': lbry_file.completed,
@ -917,23 +888,13 @@ class Daemon(AuthJSONRPCServer):
'stream_name': lbry_file.stream_name,
'suggested_file_name': lbry_file.suggested_file_name,
'sd_hash': lbry_file.sd_hash,
'name': lbry_file.name,
'outpoint': outpoint,
'claim_id': lbry_file.claim_id,
'download_path': full_path,
'mime_type': mime_type,
'key': key,
'total_bytes': size,
'written_bytes': written_bytes,
'message': message,
'metadata': metadata
}
if channel_name is not None:
result['channel_name'] = channel_name
if has_signature is not None:
result['has_signature'] = has_signature
if signature_is_valid is not None:
result['signature_is_valid'] = signature_is_valid
defer.returnValue(result)
@defer.inlineCallbacks
@ -1292,8 +1253,7 @@ class Daemon(AuthJSONRPCServer):
Usage:
file_list [--sd_hash=<sd_hash>] [--file_name=<file_name>] [--stream_hash=<stream_hash>]
[--claim_id=<claim_id>] [--outpoint=<outpoint>] [--rowid=<rowid>]
[--name=<name>]
[--rowid=<rowid>]
[-f]
Options:
@ -1301,10 +1261,7 @@ class Daemon(AuthJSONRPCServer):
--file_name=<file_name> : get file with matching file name in the
downloads folder
--stream_hash=<stream_hash> : get file with matching stream hash
--claim_id=<claim_id> : get file with matching claim id
--outpoint=<outpoint> : get file with matching claim outpoint
--rowid=<rowid> : get file with matching row id
--name=<name> : get file with matching associated name claim
-f : full status, populate the 'message' and 'size' fields
Returns:
@ -1321,16 +1278,12 @@ class Daemon(AuthJSONRPCServer):
'stream_name': (str) stream name ,
'suggested_file_name': (str) suggested file name,
'sd_hash': (str) sd hash of file,
'name': (str) name claim attached to file
'outpoint': (str) claim outpoint attached to file
'claim_id': (str) claim ID attached to file,
'download_path': (str) download path of file,
'mime_type': (str) mime type of file,
'key': (str) key attached to file,
'total_bytes': (int) file size in bytes, None if full_status is false
'written_bytes': (int) written size in bytes
'message': (str), None if full_status is false
'metadata': (dict) Metadata dictionary
},
]
"""
@ -1644,10 +1597,7 @@ class Daemon(AuthJSONRPCServer):
--sd_hash=<sd_hash> : delete by file sd hash
--file_name<file_name> : delete by file name in downloads folder
--stream_hash=<stream_hash> : delete by file stream hash
--claim_id=<claim_id> : delete by file claim id
--outpoint=<outpoint> : delete by file claim outpoint
--rowid=<rowid> : delete by file row id
--name=<name> : delete by associated name claim of file
Returns:
(bool) true if deletion was successful
@ -2699,10 +2649,7 @@ class Daemon(AuthJSONRPCServer):
--file_name=<file_name> : get file with matching file name in the
downloads folder
--stream_hash=<stream_hash> : get file with matching stream hash
--claim_id=<claim_id> : get file with matching claim id
--outpoint=<outpoint> : get file with matching claim outpoint
--rowid=<rowid> : get file with matching row id
--name=<name> : get file with matching associated name claim
--reflector=<reflector> : reflector server, ip address or url
by default choose a server from the config

View file

@ -7,7 +7,7 @@ from zope.interface import implements
from twisted.internet import defer
from lbrynet.core.client.StreamProgressManager import FullStreamProgressManager
from lbrynet.core.Error import NoSuchSDHash, NoSuchStreamHash
from lbrynet.core.Error import NoSuchStreamHash
from lbrynet.core.utils import short_hash
from lbrynet.core.StreamDescriptor import StreamMetadata
from lbrynet.lbry_file.client.EncryptedFileDownloader import EncryptedFileSaver
@ -15,12 +15,11 @@ from lbrynet.lbry_file.client.EncryptedFileDownloader import EncryptedFileDownlo
from lbrynet.file_manager.EncryptedFileStatusReport import EncryptedFileStatusReport
from lbrynet.interfaces import IStreamDownloaderFactory
from lbrynet.lbry_file.StreamDescriptor import save_sd_info
from lbrynet.core.Wallet import ClaimOutpoint
log = logging.getLogger(__name__)
def log_status(name, sd_hash, status):
def log_status(file_name, sd_hash, status):
if status == ManagedEncryptedFileDownloader.STATUS_RUNNING:
status_string = "running"
elif status == ManagedEncryptedFileDownloader.STATUS_STOPPED:
@ -29,7 +28,7 @@ def log_status(name, sd_hash, status):
status_string = "finished"
else:
status_string = "unknown"
log.info("lbry://%s (%s) is %s", name, short_hash(sd_hash), status_string)
log.info("%s (%s) is %s", file_name, short_hash(sd_hash), status_string)
class ManagedEncryptedFileDownloader(EncryptedFileSaver):
@ -48,11 +47,6 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver):
download_directory,
file_name)
self.sd_hash = None
self.txid = None
self.nout = None
self.outpoint = None
self.name = None
self.claim_id = None
self.rowid = rowid
self.lbry_file_manager = lbry_file_manager
self._saving_status = False
@ -66,7 +60,7 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver):
yield self.load_file_attributes()
status = yield self.lbry_file_manager.get_lbry_file_status(self)
log_status(self.name, self.sd_hash, status)
log_status(self.file_name, self.sd_hash, status)
if status == ManagedEncryptedFileDownloader.STATUS_RUNNING:
# start returns self.finished_deferred
@ -118,16 +112,6 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver):
else:
self.sd_hash = sd_hash
stream_metadata = yield self.wallet.get_claim_metadata_for_sd_hash(self.sd_hash)
if stream_metadata:
name, txid, nout = stream_metadata
self.name = name
self.txid = txid
self.nout = nout
self.outpoint = ClaimOutpoint(self.txid, self.nout)
else:
raise NoSuchSDHash(self.sd_hash)
self.claim_id = yield self.wallet.get_claimid(self.txid, self.nout)
defer.returnValue(None)
@defer.inlineCallbacks
@ -135,7 +119,7 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver):
yield EncryptedFileSaver._start(self)
yield self.load_file_attributes()
status = yield self._save_status()
log_status(self.name, self.sd_hash, status)
log_status(self.file_name, self.sd_hash, status)
defer.returnValue(status)
def _get_finished_deferred_callback_value(self):