diff --git a/lbrynet/lbryfile/FileMetadataManager.py b/lbrynet/lbryfile/FileMetadataManager.py index af84024d2..50ecf605d 100644 --- a/lbrynet/lbryfile/FileMetadataManager.py +++ b/lbrynet/lbryfile/FileMetadataManager.py @@ -11,7 +11,7 @@ from lbrynet.core.sqlite_helpers import rerun_if_locked log = logging.getLogger(__name__) -class DBLBRYFileMetadataManager(object): +class DBEncryptedFileMetadataManager(object): """Store and provide access to LBRY file metadata using sqlite""" def __init__(self, db_dir): @@ -243,7 +243,7 @@ class DBLBRYFileMetadataManager(object): return d -class TempLBRYFileMetadataManager(object): +class TempEncryptedFileMetadataManager(object): def __init__(self): self.streams = {} self.stream_blobs = {} diff --git a/lbrynet/lbryfile/StreamDescriptor.py b/lbrynet/lbryfile/StreamDescriptor.py index 0a7b4c46a..a91c3ccf6 100644 --- a/lbrynet/lbryfile/StreamDescriptor.py +++ b/lbrynet/lbryfile/StreamDescriptor.py @@ -11,7 +11,7 @@ import os log = logging.getLogger(__name__) -LBRYFileStreamType = "lbryfile" +EncryptedFileStreamType = "lbryfile" def save_sd_info(stream_info_manager, sd_info, ignore_duplicate=False): @@ -50,7 +50,7 @@ def get_sd_info(stream_info_manager, stream_hash, include_blobs): def format_info(stream_info): fields = {} - fields['stream_type'] = LBRYFileStreamType + fields['stream_type'] = EncryptedFileStreamType fields['stream_name'] = stream_info[1] fields['key'] = stream_info[0] fields['suggested_file_name'] = stream_info[2] @@ -121,7 +121,7 @@ def create_plain_sd(stream_info_manager, stream_hash, file_name, overwrite_exist return d -class LBRYFileStreamDescriptorValidator(object): +class EncryptedFileStreamDescriptorValidator(object): def __init__(self, raw_info): self.raw_info = raw_info diff --git a/lbrynet/lbryfile/client/FileDownloader.py b/lbrynet/lbryfile/client/FileDownloader.py index 16ee9425d..f3c08d6e9 100644 --- a/lbrynet/lbryfile/client/FileDownloader.py +++ b/lbrynet/lbryfile/client/FileDownloader.py @@ -8,7 +8,7 @@ from lbrynet.cryptstream.client.CryptStreamDownloader import CryptStreamDownload from lbrynet.core.client.StreamProgressManager import FullStreamProgressManager from lbrynet.core.StreamDescriptor import StreamMetadata from lbrynet.interfaces import IStreamDownloaderFactory -from lbrynet.lbryfile.client.LBRYFileMetadataHandler import LBRYFileMetadataHandler +from lbrynet.lbryfile.client.EncryptedFileMetadataHandler import EncryptedFileMetadataHandler import os from twisted.internet import defer, threads, reactor from twisted.python.procutils import which @@ -19,7 +19,7 @@ import traceback log = logging.getLogger(__name__) -class LBRYFileDownloader(CryptStreamDownloader): +class EncryptedFileDownloader(CryptStreamDownloader): """Classes which inherit from this class download LBRY files""" def __init__(self, stream_hash, peer_finder, rate_limiter, blob_manager, @@ -120,10 +120,10 @@ class LBRYFileDownloader(CryptStreamDownloader): return 0 def _get_metadata_handler(self, download_manager): - return LBRYFileMetadataHandler(self.stream_hash, self.stream_info_manager, download_manager) + return EncryptedFileMetadataHandler(self.stream_hash, self.stream_info_manager, download_manager) -class LBRYFileDownloaderFactory(object): +class EncryptedFileDownloaderFactory(object): implements(IStreamDownloaderFactory) def __init__(self, peer_finder, rate_limiter, blob_manager, stream_info_manager, @@ -165,10 +165,10 @@ class LBRYFileDownloaderFactory(object): pass -class LBRYFileSaver(LBRYFileDownloader): +class EncryptedFileSaver(EncryptedFileDownloader): def __init__(self, stream_hash, peer_finder, rate_limiter, blob_manager, stream_info_manager, payment_rate_manager, wallet, download_directory, upload_allowed, file_name=None): - LBRYFileDownloader.__init__(self, stream_hash, peer_finder, rate_limiter, blob_manager, + EncryptedFileDownloader.__init__(self, stream_hash, peer_finder, rate_limiter, blob_manager, stream_info_manager, payment_rate_manager, wallet, upload_allowed) self.download_directory = download_directory self.file_name = file_name @@ -182,7 +182,7 @@ class LBRYFileSaver(LBRYFileDownloader): return str(self.file_name) def set_stream_info(self): - d = LBRYFileDownloader.set_stream_info(self) + d = EncryptedFileDownloader.set_stream_info(self) def set_file_name(): if self.file_name is None: @@ -195,7 +195,7 @@ class LBRYFileSaver(LBRYFileDownloader): return d def stop(self, err=None): - d = LBRYFileDownloader.stop(self, err=err) + d = EncryptedFileDownloader.stop(self, err=err) d.addCallback(lambda _: self._delete_from_info_manager()) return d @@ -257,15 +257,15 @@ class LBRYFileSaver(LBRYFileDownloader): return self.stream_info_manager.delete_stream(self.stream_hash) -class LBRYFileSaverFactory(LBRYFileDownloaderFactory): +class EncryptedFileSaverFactory(EncryptedFileDownloaderFactory): def __init__(self, peer_finder, rate_limiter, blob_manager, stream_info_manager, wallet, download_directory): - LBRYFileDownloaderFactory.__init__(self, peer_finder, rate_limiter, blob_manager, + EncryptedFileDownloaderFactory.__init__(self, peer_finder, rate_limiter, blob_manager, stream_info_manager, wallet) self.download_directory = download_directory def _make_downloader(self, stream_hash, payment_rate_manager, stream_info, upload_allowed): - return LBRYFileSaver(stream_hash, self.peer_finder, self.rate_limiter, self.blob_manager, + return EncryptedFileSaver(stream_hash, self.peer_finder, self.rate_limiter, self.blob_manager, self.stream_info_manager, payment_rate_manager, self.wallet, self.download_directory, upload_allowed) @@ -274,16 +274,16 @@ class LBRYFileSaverFactory(LBRYFileDownloaderFactory): return "Save" -class LBRYFileOpener(LBRYFileDownloader): +class EncryptedFileOpener(EncryptedFileDownloader): def __init__(self, stream_hash, peer_finder, rate_limiter, blob_manager, stream_info_manager, payment_rate_manager, wallet, upload_allowed): - LBRYFileDownloader.__init__(self, stream_hash, peer_finder, rate_limiter, blob_manager, + EncryptedFileDownloader.__init__(self, stream_hash, peer_finder, rate_limiter, blob_manager, stream_info_manager, payment_rate_manager, wallet, upload_allowed) self.process = None self.process_log = None def stop(self, err=None): - d = LBRYFileDownloader.stop(self, err=err) + d = EncryptedFileDownloader.stop(self, err=err) d.addCallback(lambda _: self._delete_from_info_manager()) return d @@ -333,7 +333,7 @@ class LBRYFileOpener(LBRYFileDownloader): return self.stream_info_manager.delete_stream(self.stream_hash) -class LBRYFileOpenerFactory(LBRYFileDownloaderFactory): +class EncryptedFileOpenerFactory(EncryptedFileDownloaderFactory): def can_download(self, sd_validator): if which('vlc'): return True @@ -346,7 +346,7 @@ class LBRYFileOpenerFactory(LBRYFileDownloaderFactory): return False def _make_downloader(self, stream_hash, payment_rate_manager, stream_info, upload_allowed): - return LBRYFileOpener(stream_hash, self.peer_finder, self.rate_limiter, self.blob_manager, + return EncryptedFileOpener(stream_hash, self.peer_finder, self.rate_limiter, self.blob_manager, self.stream_info_manager, payment_rate_manager, self.wallet, upload_allowed) @staticmethod diff --git a/lbrynet/lbryfile/client/FileMetadataHandler.py b/lbrynet/lbryfile/client/FileMetadataHandler.py index 65d95c977..1444a61a3 100644 --- a/lbrynet/lbryfile/client/FileMetadataHandler.py +++ b/lbrynet/lbryfile/client/FileMetadataHandler.py @@ -7,7 +7,7 @@ from lbrynet.interfaces import IMetadataHandler log = logging.getLogger(__name__) -class LBRYFileMetadataHandler(object): +class EncryptedFileMetadataHandler(object): implements(IMetadataHandler) def __init__(self, stream_hash, stream_info_manager, download_manager): diff --git a/lbrynet/lbryfile/client/FileOptions.py b/lbrynet/lbryfile/client/FileOptions.py index 551448a15..fc3423708 100644 --- a/lbrynet/lbryfile/client/FileOptions.py +++ b/lbrynet/lbryfile/client/FileOptions.py @@ -1,12 +1,12 @@ -from lbrynet.lbryfile.StreamDescriptor import LBRYFileStreamType, LBRYFileStreamDescriptorValidator +from lbrynet.lbryfile.StreamDescriptor import EncryptedFileStreamType, EncryptedFileStreamDescriptorValidator from lbrynet.core.DownloadOption import DownloadOption, DownloadOptionChoice def add_lbry_file_to_sd_identifier(sd_identifier): - sd_identifier.add_stream_type(LBRYFileStreamType, LBRYFileStreamDescriptorValidator, LBRYFileOptions()) + sd_identifier.add_stream_type(EncryptedFileStreamType, EncryptedFileStreamDescriptorValidator, EncryptedFileOptions()) -class LBRYFileOptions(object): +class EncryptedFileOptions(object): def __init__(self): pass diff --git a/lbrynet/lbryfilemanager/FileCreator.py b/lbrynet/lbryfilemanager/FileCreator.py index 876cd6542..e050ae62f 100644 --- a/lbrynet/lbryfilemanager/FileCreator.py +++ b/lbrynet/lbryfilemanager/FileCreator.py @@ -16,9 +16,9 @@ from twisted.protocols.basic import FileSender log = logging.getLogger(__name__) -class LBRYFileStreamCreator(CryptStreamCreator): +class EncryptedFileStreamCreator(CryptStreamCreator): """ - A CryptStreamCreator which adds itself and its additional metadata to an LBRYFileManager + A CryptStreamCreator which adds itself and its additional metadata to an EncryptedFileManager """ def __init__(self, blob_manager, lbry_file_manager, name=None, key=None, iv_generator=None, suggested_file_name=None): @@ -96,8 +96,8 @@ def create_lbry_file(session, lbry_file_manager, file_name, file_handle, key=Non @param session: An LBRYSession object. @type session: LBRYSession - @param lbry_file_manager: The LBRYFileManager object this LBRY File will be added to. - @type lbry_file_manager: LBRYFileManager + @param lbry_file_manager: The EncryptedFileManager object this LBRY File will be added to. + @type lbry_file_manager: EncryptedFileManager @param file_name: The path to the plain file. @type file_name: string @@ -141,7 +141,7 @@ def create_lbry_file(session, lbry_file_manager, file_name, file_handle, key=Non base_file_name = os.path.basename(file_name) - lbry_file_creator = LBRYFileStreamCreator(session.blob_manager, lbry_file_manager, base_file_name, + lbry_file_creator = EncryptedFileStreamCreator(session.blob_manager, lbry_file_manager, base_file_name, key, iv_generator, suggested_file_name) def start_stream(): diff --git a/lbrynet/lbryfilemanager/FileDownloader.py b/lbrynet/lbryfilemanager/FileDownloader.py index 653e9fd01..5d9ab5a0d 100644 --- a/lbrynet/lbryfilemanager/FileDownloader.py +++ b/lbrynet/lbryfilemanager/FileDownloader.py @@ -5,8 +5,8 @@ Download LBRY Files from LBRYnet and save them to disk. from zope.interface import implements from lbrynet.core.client.StreamProgressManager import FullStreamProgressManager from lbrynet.core.StreamDescriptor import StreamMetadata -from lbrynet.lbryfile.client.LBRYFileDownloader import LBRYFileSaver, LBRYFileDownloader -from lbrynet.lbryfilemanager.LBRYFileStatusReport import LBRYFileStatusReport +from lbrynet.lbryfile.client.EncryptedFileDownloader import EncryptedFileSaver, EncryptedFileDownloader +from lbrynet.lbryfilemanager.EncryptedFileStatusReport import EncryptedFileStatusReport from lbrynet.interfaces import IStreamDownloaderFactory from lbrynet.lbryfile.StreamDescriptor import save_sd_info from twisted.internet import defer @@ -15,7 +15,7 @@ import logging log = logging.getLogger(__name__) -class ManagedLBRYFileDownloader(LBRYFileSaver): +class ManagedEncryptedFileDownloader(EncryptedFileSaver): STATUS_RUNNING = "running" STATUS_STOPPED = "stopped" @@ -24,7 +24,7 @@ class ManagedLBRYFileDownloader(LBRYFileSaver): def __init__(self, rowid, stream_hash, peer_finder, rate_limiter, blob_manager, stream_info_manager, lbry_file_manager, payment_rate_manager, wallet, download_directory, upload_allowed, file_name=None): - LBRYFileSaver.__init__(self, stream_hash, peer_finder, rate_limiter, blob_manager, + EncryptedFileSaver.__init__(self, stream_hash, peer_finder, rate_limiter, blob_manager, stream_info_manager, payment_rate_manager, wallet, download_directory, upload_allowed, file_name) self.sd_hash = None @@ -68,11 +68,11 @@ class ManagedLBRYFileDownloader(LBRYFileSaver): d.addCallback(lambda _: self.lbry_file_manager.get_lbry_file_status(self)) def restore_status(status): - if status == ManagedLBRYFileDownloader.STATUS_RUNNING: + if status == ManagedEncryptedFileDownloader.STATUS_RUNNING: return self.start() - elif status == ManagedLBRYFileDownloader.STATUS_STOPPED: + elif status == ManagedEncryptedFileDownloader.STATUS_STOPPED: return defer.succeed(False) - elif status == ManagedLBRYFileDownloader.STATUS_FINISHED: + elif status == ManagedEncryptedFileDownloader.STATUS_FINISHED: self.completed = True return defer.succeed(True) @@ -84,7 +84,7 @@ class ManagedLBRYFileDownloader(LBRYFileSaver): def set_saving_status_done(): self.saving_status = False - d = LBRYFileDownloader.stop(self, err=err) # LBRYFileSaver deletes metadata when it's stopped. We don't want that here. + d = EncryptedFileDownloader.stop(self, err=err) # EncryptedFileSaver deletes metadata when it's stopped. We don't want that here. if change_status is True: self.saving_status = True d.addCallback(lambda _: self._save_status()) @@ -111,7 +111,7 @@ class ManagedLBRYFileDownloader(LBRYFileSaver): s = "stopped" else: s = "running" - status = LBRYFileStatusReport(self.file_name, num_completed, num_known, s) + status = EncryptedFileStatusReport(self.file_name, num_completed, num_known, s) return status d = self.stream_info_manager.get_blobs_for_stream(self.stream_hash) @@ -121,7 +121,7 @@ class ManagedLBRYFileDownloader(LBRYFileSaver): def _start(self): - d = LBRYFileSaver._start(self) + d = EncryptedFileSaver._start(self) d.addCallback(lambda _: self.stream_info_manager._get_sd_blob_hashes_for_stream(self.stream_hash)) @@ -153,18 +153,18 @@ class ManagedLBRYFileDownloader(LBRYFileSaver): def _save_status(self): if self.completed is True: - s = ManagedLBRYFileDownloader.STATUS_FINISHED + s = ManagedEncryptedFileDownloader.STATUS_FINISHED elif self.stopped is True: - s = ManagedLBRYFileDownloader.STATUS_STOPPED + s = ManagedEncryptedFileDownloader.STATUS_STOPPED else: - s = ManagedLBRYFileDownloader.STATUS_RUNNING + s = ManagedEncryptedFileDownloader.STATUS_RUNNING return self.lbry_file_manager.change_lbry_file_status(self, s) def _get_progress_manager(self, download_manager): return FullStreamProgressManager(self._finished_downloading, self.blob_manager, download_manager) -class ManagedLBRYFileDownloaderFactory(object): +class ManagedEncryptedFileDownloaderFactory(object): implements(IStreamDownloaderFactory) def __init__(self, lbry_file_manager): diff --git a/lbrynet/lbryfilemanager/FileManager.py b/lbrynet/lbryfilemanager/FileManager.py index afde816ea..20c9690a7 100644 --- a/lbrynet/lbryfilemanager/FileManager.py +++ b/lbrynet/lbryfilemanager/FileManager.py @@ -9,9 +9,9 @@ from twisted.enterprise import adbapi from twisted.internet import defer, task, reactor from twisted.python.failure import Failure -from lbrynet.lbryfilemanager.LBRYFileDownloader import ManagedLBRYFileDownloader -from lbrynet.lbryfilemanager.LBRYFileDownloader import ManagedLBRYFileDownloaderFactory -from lbrynet.lbryfile.StreamDescriptor import LBRYFileStreamType +from lbrynet.lbryfilemanager.EncryptedFileDownloader import ManagedEncryptedFileDownloader +from lbrynet.lbryfilemanager.EncryptedFileDownloader import ManagedEncryptedFileDownloaderFactory +from lbrynet.lbryfile.StreamDescriptor import EncryptedFileStreamType from lbrynet.core.PaymentRateManager import PaymentRateManager from lbrynet.cryptstream.client.CryptStreamDownloader import AlreadyStoppedError, CurrentlyStoppingError from lbrynet.core.sqlite_helpers import rerun_if_locked @@ -20,7 +20,7 @@ from lbrynet.core.sqlite_helpers import rerun_if_locked log = logging.getLogger(__name__) -class LBRYFileManager(object): +class EncryptedFileManager(object): """ Keeps track of currently opened LBRY Files, their options, and their LBRY File specific metadata. """ @@ -35,7 +35,7 @@ class LBRYFileManager(object): self.download_directory = download_directory else: self.download_directory = os.getcwd() - log.debug("Download directory for LBRYFileManager: %s", str(self.download_directory)) + log.debug("Download directory for EncryptedFileManager: %s", str(self.download_directory)) def setup(self): d = self._open_db() @@ -68,8 +68,8 @@ class LBRYFileManager(object): return dl def _add_to_sd_identifier(self): - downloader_factory = ManagedLBRYFileDownloaderFactory(self) - self.sd_identifier.add_stream_downloader_factory(LBRYFileStreamType, downloader_factory) + downloader_factory = ManagedEncryptedFileDownloaderFactory(self) + self.sd_identifier.add_stream_downloader_factory(EncryptedFileStreamType, downloader_factory) def _start_lbry_files(self): @@ -101,7 +101,7 @@ class LBRYFileManager(object): if not download_directory: download_directory = self.download_directory payment_rate_manager.min_blob_data_payment_rate = blob_data_rate - lbry_file_downloader = ManagedLBRYFileDownloader(rowid, stream_hash, + lbry_file_downloader = ManagedEncryptedFileDownloader(rowid, stream_hash, self.session.peer_finder, self.session.rate_limiter, self.session.blob_manager, @@ -207,7 +207,7 @@ class LBRYFileManager(object): def _save_lbry_file(self, stream_hash, data_payment_rate): def do_save(db_transaction): db_transaction.execute("insert into lbry_file_options values (?, ?, ?)", - (data_payment_rate, ManagedLBRYFileDownloader.STATUS_STOPPED, + (data_payment_rate, ManagedEncryptedFileDownloader.STATUS_STOPPED, stream_hash)) return db_transaction.lastrowid return self.sql_db.runInteraction(do_save) @@ -236,7 +236,7 @@ class LBRYFileManager(object): def _get_lbry_file_status(self, rowid): d = self.sql_db.runQuery("select status from lbry_file_options where rowid = ?", (rowid,)) - d.addCallback(lambda r: r[0][0] if len(r) else ManagedLBRYFileDownloader.STATUS_STOPPED) + d.addCallback(lambda r: r[0][0] if len(r) else ManagedEncryptedFileDownloader.STATUS_STOPPED) return d @rerun_if_locked diff --git a/lbrynet/lbryfilemanager/FileStatusReport.py b/lbrynet/lbryfilemanager/FileStatusReport.py index d434e1283..2062c5ff7 100644 --- a/lbrynet/lbryfilemanager/FileStatusReport.py +++ b/lbrynet/lbryfilemanager/FileStatusReport.py @@ -1,4 +1,4 @@ -class LBRYFileStatusReport(object): +class EncryptedFileStatusReport(object): def __init__(self, name, num_completed, num_known, running_status): self.name = name self.num_completed = num_completed diff --git a/lbrynet/lbrynet_console/Console.py b/lbrynet/lbrynet_console/Console.py index 468bc267a..5ae2069ff 100644 --- a/lbrynet/lbrynet_console/Console.py +++ b/lbrynet/lbrynet_console/Console.py @@ -15,7 +15,7 @@ from jsonrpc.proxy import JSONRPCProxy from lbrynet.core.Session import LBRYSession from lbrynet.lbrynet_console.ConsoleControl import ConsoleControl from lbrynet.lbrynet_console.LBRYSettings import LBRYSettings -from lbrynet.lbryfilemanager.LBRYFileManager import LBRYFileManager +from lbrynet.lbryfilemanager.EncryptedFileManager import EncryptedFileManager from lbrynet.conf import MIN_BLOB_DATA_PAYMENT_RATE, API_CONNECTION_STRING # , MIN_BLOB_INFO_PAYMENT_RATE from lbrynet.core.utils import generate_id from lbrynet.core.StreamDescriptor import StreamDescriptorIdentifier @@ -24,23 +24,23 @@ from lbrynet.core.server.BlobAvailabilityHandler import BlobAvailabilityHandlerF from lbrynet.core.server.BlobRequestHandler import BlobRequestHandlerFactory from lbrynet.core.server.ServerProtocol import ServerProtocolFactory from lbrynet.core.PTCWallet import PTCWallet -from lbrynet.lbryfile.client.LBRYFileOptions import add_lbry_file_to_sd_identifier -from lbrynet.lbryfile.client.LBRYFileDownloader import LBRYFileOpenerFactory -from lbrynet.lbryfile.StreamDescriptor import LBRYFileStreamType -from lbrynet.lbryfile.LBRYFileMetadataManager import DBLBRYFileMetadataManager, TempLBRYFileMetadataManager +from lbrynet.lbryfile.client.EncryptedFileOptions import add_lbry_file_to_sd_identifier +from lbrynet.lbryfile.client.EncryptedFileDownloader import EncryptedFileOpenerFactory +from lbrynet.lbryfile.StreamDescriptor import EncryptedFileStreamType +from lbrynet.lbryfile.EncryptedFileMetadataManager import DBEncryptedFileMetadataManager, TempEncryptedFileMetadataManager from lbrynet.lbrynet_console.ControlHandlers import ApplicationStatusFactory, GetWalletBalancesFactory, ShutDownFactory from lbrynet.lbrynet_console.ControlHandlers import ImmediateAnnounceAllBlobsFactory -from lbrynet.lbrynet_console.ControlHandlers import LBRYFileStatusFactory, DeleteLBRYFileChooserFactory -from lbrynet.lbrynet_console.ControlHandlers import ToggleLBRYFileRunningChooserFactory +from lbrynet.lbrynet_console.ControlHandlers import EncryptedFileStatusFactory, DeleteEncryptedFileChooserFactory +from lbrynet.lbrynet_console.ControlHandlers import ToggleEncryptedFileRunningChooserFactory from lbrynet.lbrynet_console.ControlHandlers import ModifyApplicationDefaultsFactory -from lbrynet.lbrynet_console.ControlHandlers import CreateLBRYFileFactory, PublishStreamDescriptorChooserFactory +from lbrynet.lbrynet_console.ControlHandlers import CreateEncryptedFileFactory, PublishStreamDescriptorChooserFactory from lbrynet.lbrynet_console.ControlHandlers import ShowPublishedSDHashesChooserFactory from lbrynet.lbrynet_console.ControlHandlers import CreatePlainStreamDescriptorChooserFactory -from lbrynet.lbrynet_console.ControlHandlers import ShowLBRYFileStreamHashChooserFactory, AddStreamFromHashFactory +from lbrynet.lbrynet_console.ControlHandlers import ShowEncryptedFileStreamHashChooserFactory, AddStreamFromHashFactory from lbrynet.lbrynet_console.ControlHandlers import AddStreamFromSDFactory, AddStreamFromLBRYcrdNameFactory from lbrynet.lbrynet_console.ControlHandlers import ClaimNameFactory, GetNewWalletAddressFactory from lbrynet.lbrynet_console.ControlHandlers import ShowServerStatusFactory, ModifyServerSettingsFactory -from lbrynet.lbrynet_console.ControlHandlers import ModifyLBRYFileOptionsChooserFactory, StatusFactory +from lbrynet.lbrynet_console.ControlHandlers import ModifyEncryptedFileOptionsChooserFactory, StatusFactory from lbrynet.lbrynet_console.ControlHandlers import PeerStatsAndSettingsChooserFactory, PublishFactory from lbrynet.lbrynet_console.ControlHandlers import BlockchainStatusFactory from lbrynet.core.LBRYWallet import LBRYcrdWallet, LBRYumWallet @@ -297,11 +297,11 @@ class LBRYConsole(): "catch up with our blockchain.\n", points_string) def _setup_lbry_file_manager(self): - self.lbry_file_metadata_manager = DBLBRYFileMetadataManager(self.db_dir) + self.lbry_file_metadata_manager = DBEncryptedFileMetadataManager(self.db_dir) d = self.lbry_file_metadata_manager.setup() def set_lbry_file_manager(): - self.lbry_file_manager = LBRYFileManager(self.session, self.lbry_file_metadata_manager, self.sd_identifier) + self.lbry_file_manager = EncryptedFileManager(self.session, self.lbry_file_metadata_manager, self.sd_identifier) return self.lbry_file_manager.setup() d.addCallback(lambda _: set_lbry_file_manager()) @@ -309,11 +309,11 @@ class LBRYConsole(): return d def _setup_lbry_file_opener(self): - stream_info_manager = TempLBRYFileMetadataManager() - downloader_factory = LBRYFileOpenerFactory(self.session.peer_finder, self.session.rate_limiter, + stream_info_manager = TempEncryptedFileMetadataManager() + downloader_factory = EncryptedFileOpenerFactory(self.session.peer_finder, self.session.rate_limiter, self.session.blob_manager, stream_info_manager, self.session.wallet) - self.sd_identifier.add_stream_downloader_factory(LBRYFileStreamType, downloader_factory) + self.sd_identifier.add_stream_downloader_factory(EncryptedFileStreamType, downloader_factory) return defer.succeed(True) def _setup_control_handlers(self): @@ -323,20 +323,20 @@ class LBRYConsole(): ModifyApplicationDefaultsFactory(self), ShutDownFactory(self), PeerStatsAndSettingsChooserFactory(self.session.peer_manager), - LBRYFileStatusFactory(self.lbry_file_manager), + EncryptedFileStatusFactory(self.lbry_file_manager), AddStreamFromSDFactory(self.sd_identifier, self.session.base_payment_rate_manager, self.session.wallet), - DeleteLBRYFileChooserFactory(self.lbry_file_metadata_manager, self.session.blob_manager, + DeleteEncryptedFileChooserFactory(self.lbry_file_metadata_manager, self.session.blob_manager, self.lbry_file_manager), - ToggleLBRYFileRunningChooserFactory(self.lbry_file_manager), - CreateLBRYFileFactory(self.session, self.lbry_file_manager), + ToggleEncryptedFileRunningChooserFactory(self.lbry_file_manager), + CreateEncryptedFileFactory(self.session, self.lbry_file_manager), PublishStreamDescriptorChooserFactory(self.lbry_file_metadata_manager, self.session.blob_manager), ShowPublishedSDHashesChooserFactory(self.lbry_file_metadata_manager, self.lbry_file_manager), CreatePlainStreamDescriptorChooserFactory(self.lbry_file_manager), - ShowLBRYFileStreamHashChooserFactory(self.lbry_file_manager), - ModifyLBRYFileOptionsChooserFactory(self.lbry_file_manager), + ShowEncryptedFileStreamHashChooserFactory(self.lbry_file_manager), + ModifyEncryptedFileOptionsChooserFactory(self.lbry_file_manager), AddStreamFromHashFactory(self.sd_identifier, self.session, self.session.wallet), StatusFactory(self, self.session.rate_limiter, self.lbry_file_manager, self.session.blob_manager, self.session.wallet if not self.fake_wallet else None), diff --git a/lbrynet/lbrynet_console/ControlHandlers.py b/lbrynet/lbrynet_console/ControlHandlers.py index 42e9e2476..a7f5d82e7 100644 --- a/lbrynet/lbrynet_console/ControlHandlers.py +++ b/lbrynet/lbrynet_console/ControlHandlers.py @@ -2,8 +2,8 @@ import logging from zope.interface import implements from lbrynet.core.PaymentRateManager import PaymentRateManager -from lbrynet.lbryfilemanager.LBRYFileCreator import create_lbry_file -from lbrynet.lbryfilemanager.LBRYFileDownloader import ManagedLBRYFileDownloader +from lbrynet.lbryfilemanager.EncryptedFileCreator import create_lbry_file +from lbrynet.lbryfilemanager.EncryptedFileDownloader import ManagedEncryptedFileDownloader from lbrynet.lbryfile.StreamDescriptor import publish_sd_blob, create_plain_sd from lbrynet.lbrynet_console.interfaces import ICommandHandler, ICommandHandlerFactory from lbrynet.core.StreamDescriptor import download_sd_blob @@ -418,7 +418,7 @@ class ShutDownFactory(CommandHandlerFactory): full_help = "Shut down" -class LBRYFileStatus(CommandHandler): +class EncryptedFileStatus(CommandHandler): #prompt_description = "Print status information for all LBRY Files" def __init__(self, console, lbry_file_manager): @@ -446,8 +446,8 @@ class LBRYFileStatus(CommandHandler): self.console.sendLine(''.join(status_strings)) -class LBRYFileStatusFactory(CommandHandlerFactory): - control_handler_class = LBRYFileStatus +class EncryptedFileStatusFactory(CommandHandlerFactory): + control_handler_class = EncryptedFileStatus command = "lbryfile-status" short_help = "Print status information for LBRY files" full_help = "Print the status information for all streams that are being saved to disk." \ @@ -988,7 +988,7 @@ class AddStreamFromLBRYcrdNameFactory(CommandHandlerFactory): "Usage: get " -class LBRYFileChooser(RecursiveCommandHandler): +class EncryptedFileChooser(RecursiveCommandHandler): def __init__(self, console, lbry_file_manager, factory_class, *args, **kwargs): """ @@ -1014,23 +1014,23 @@ class LBRYFileChooser(RecursiveCommandHandler): return control_handler_factories -class LBRYFileChooserFactory(CommandHandlerFactory): +class EncryptedFileChooserFactory(CommandHandlerFactory): def get_prompt_description(self): lbry_file = self.args[0] return lbry_file.file_name -class DeleteLBRYFileChooser(LBRYFileChooser): +class DeleteEncryptedFileChooser(EncryptedFileChooser): #prompt_description = "Delete LBRY File" def __init__(self, console, stream_info_manager, blob_manager, lbry_file_manager): - LBRYFileChooser.__init__(self, console, lbry_file_manager, DeleteLBRYFileFactory, + EncryptedFileChooser.__init__(self, console, lbry_file_manager, DeleteEncryptedFileFactory, stream_info_manager, blob_manager, lbry_file_manager, exit_after_one_done=True) -class DeleteLBRYFileChooserFactory(CommandHandlerFactory): - control_handler_class = DeleteLBRYFileChooser +class DeleteEncryptedFileChooserFactory(CommandHandlerFactory): + control_handler_class = DeleteEncryptedFileChooser command = "delete-lbryfile" short_help = "Delete an LBRY file" full_help = "Delete an LBRY file which has been downloaded or created by this application.\n" \ @@ -1040,7 +1040,7 @@ class DeleteLBRYFileChooserFactory(CommandHandlerFactory): "not be able to upload those chunks of data to other peers on LBRYnet." -class DeleteLBRYFile(CommandHandler): +class DeleteEncryptedFile(CommandHandler): #prompt_description = "Delete LBRY File" delete_data_prompt = "Also delete data? (y/n): " confirm_prompt = "Are you sure? (y/n): " @@ -1106,27 +1106,27 @@ class DeleteLBRYFile(CommandHandler): return d -class DeleteLBRYFileFactory(LBRYFileChooserFactory): - control_handler_class = DeleteLBRYFile +class DeleteEncryptedFileFactory(EncryptedFileChooserFactory): + control_handler_class = DeleteEncryptedFile -class ToggleLBRYFileRunningChooser(LBRYFileChooser): +class ToggleEncryptedFileRunningChooser(EncryptedFileChooser): #prompt_description = "Toggle whether an LBRY File is running" def __init__(self, console, lbry_file_manager): - LBRYFileChooser.__init__(self, console, lbry_file_manager, ToggleLBRYFileRunningFactory, + EncryptedFileChooser.__init__(self, console, lbry_file_manager, ToggleEncryptedFileRunningFactory, lbry_file_manager, exit_after_one_done=True) -class ToggleLBRYFileRunningChooserFactory(CommandHandlerFactory): - control_handler_class = ToggleLBRYFileRunningChooser +class ToggleEncryptedFileRunningChooserFactory(CommandHandlerFactory): + control_handler_class = ToggleEncryptedFileRunningChooser command = "toggle-running" short_help = "Toggle whether an LBRY file is running" full_help = "Toggle whether an LBRY file, which is being saved by this application," \ "is currently being downloaded." -class ToggleLBRYFileRunning(CommandHandler): +class ToggleEncryptedFileRunning(CommandHandler): #prompt_description = "Toggle whether an LBRY File is running" def __init__(self, console, lbry_file, lbry_file_manager): @@ -1151,11 +1151,11 @@ class ToggleLBRYFileRunning(CommandHandler): return "An unexpected error occurred. See %s for details." % log_file -class ToggleLBRYFileRunningFactory(LBRYFileChooserFactory): - control_handler_class = ToggleLBRYFileRunning +class ToggleEncryptedFileRunningFactory(EncryptedFileChooserFactory): + control_handler_class = ToggleEncryptedFileRunning -class CreateLBRYFile(CommandHandler): +class CreateEncryptedFile(CommandHandler): #prompt_description = "Create an LBRY File from file" line_prompt = "File name: " @@ -1179,13 +1179,13 @@ class CreateLBRYFile(CommandHandler): def set_status(self, lbry_file_downloader): d = self.lbry_file_manager.change_lbry_file_status(lbry_file_downloader, - ManagedLBRYFileDownloader.STATUS_FINISHED) + ManagedEncryptedFileDownloader.STATUS_FINISHED) d.addCallback(lambda _: lbry_file_downloader.restore()) return d -class CreateLBRYFileFactory(CommandHandlerFactory): - control_handler_class = CreateLBRYFile +class CreateEncryptedFileFactory(CommandHandlerFactory): + control_handler_class = CreateEncryptedFile command = "create-lbryfile" short_help = "LBRYize a file" full_help = "Encrypt a file, split it into chunks, and make those chunks available on LBRYnet. Also " \ @@ -1196,11 +1196,11 @@ class CreateLBRYFileFactory(CommandHandlerFactory): "downloaded via the hash of the stream descriptor." -class PublishStreamDescriptorChooser(LBRYFileChooser): +class PublishStreamDescriptorChooser(EncryptedFileChooser): #prompt_description = "Publish a stream descriptor file to the DHT for an LBRY File" def __init__(self, console, stream_info_manager, blob_manager, lbry_file_manager): - LBRYFileChooser.__init__(self, console, lbry_file_manager, PublishStreamDescriptorFactory, + EncryptedFileChooser.__init__(self, console, lbry_file_manager, PublishStreamDescriptorFactory, stream_info_manager, blob_manager, lbry_file_manager, exit_after_one_done=True) @@ -1243,15 +1243,15 @@ class PublishStreamDescriptor(CommandHandler): # return d -class PublishStreamDescriptorFactory(LBRYFileChooserFactory): +class PublishStreamDescriptorFactory(EncryptedFileChooserFactory): control_handler_class = PublishStreamDescriptor -class ShowPublishedSDHashesChooser(LBRYFileChooser): +class ShowPublishedSDHashesChooser(EncryptedFileChooser): #prompt_description = "Show published stream descriptors for an LBRY File" def __init__(self, console, stream_info_manager, lbry_file_manager): - LBRYFileChooser.__init__(self, console, lbry_file_manager, ShowPublishedSDHashesFactory, + EncryptedFileChooser.__init__(self, console, lbry_file_manager, ShowPublishedSDHashesFactory, stream_info_manager, lbry_file_manager) @@ -1288,15 +1288,15 @@ class ShowPublishedSDHashes(CommandHandler): return d -class ShowPublishedSDHashesFactory(LBRYFileChooserFactory): +class ShowPublishedSDHashesFactory(EncryptedFileChooserFactory): control_handler_class = ShowPublishedSDHashes -class CreatePlainStreamDescriptorChooser(LBRYFileChooser): +class CreatePlainStreamDescriptorChooser(EncryptedFileChooser): #prompt_description = "Create a plain stream descriptor file for an LBRY File" def __init__(self, console, lbry_file_manager): - LBRYFileChooser.__init__(self, console, lbry_file_manager, + EncryptedFileChooser.__init__(self, console, lbry_file_manager, CreatePlainStreamDescriptorFactory, lbry_file_manager, exit_after_one_done=True) @@ -1352,26 +1352,26 @@ class CreatePlainStreamDescriptor(CommandHandler): return defer.succeed(file_name) -class CreatePlainStreamDescriptorFactory(LBRYFileChooserFactory): +class CreatePlainStreamDescriptorFactory(EncryptedFileChooserFactory): control_handler_class = CreatePlainStreamDescriptor -class ShowLBRYFileStreamHashChooser(LBRYFileChooser): +class ShowEncryptedFileStreamHashChooser(EncryptedFileChooser): #prompt_description = "Show an LBRY File's stream hash (not usually what you want)" def __init__(self, console, lbry_file_manager): - LBRYFileChooser.__init__(self, console, lbry_file_manager, ShowLBRYFileStreamHashFactory) + EncryptedFileChooser.__init__(self, console, lbry_file_manager, ShowEncryptedFileStreamHashFactory) -class ShowLBRYFileStreamHashChooserFactory(CommandHandlerFactory): - control_handler_class = ShowLBRYFileStreamHashChooser +class ShowEncryptedFileStreamHashChooserFactory(CommandHandlerFactory): + control_handler_class = ShowEncryptedFileStreamHashChooser command = "lbryfile-streamhash" short_help = "Show an LBRY file's stream hash" full_help = "Show the stream hash of an LBRY file, which is how the LBRY file is referenced internally" \ " by this application and therefore not usually what you want to see." -class ShowLBRYFileStreamHash(CommandHandler): +class ShowEncryptedFileStreamHash(CommandHandler): #prompt_description = "Show an LBRY File's stream hash (not usually what you want)" def __init__(self, console, lbry_file): @@ -1383,11 +1383,11 @@ class ShowLBRYFileStreamHash(CommandHandler): self.finished_deferred.callback(None) -class ShowLBRYFileStreamHashFactory(LBRYFileChooserFactory): - control_handler_class = ShowLBRYFileStreamHash +class ShowEncryptedFileStreamHashFactory(EncryptedFileChooserFactory): + control_handler_class = ShowEncryptedFileStreamHash -class ModifyLBRYFileDataPaymentRate(ModifyPaymentRate): +class ModifyEncryptedFileDataPaymentRate(ModifyPaymentRate): prompt_description = "Modify LBRY File data payment rate" def __init__(self, console, lbry_file, lbry_file_manager): @@ -1415,19 +1415,19 @@ class ModifyLBRYFileDataPaymentRate(ModifyPaymentRate): return status -class ModifyLBRYFileDataPaymentRateFactory(CommandHandlerFactory): - control_handler_class = ModifyLBRYFileDataPaymentRate +class ModifyEncryptedFileDataPaymentRateFactory(CommandHandlerFactory): + control_handler_class = ModifyEncryptedFileDataPaymentRate -class ModifyLBRYFileOptionsChooser(LBRYFileChooser): +class ModifyEncryptedFileOptionsChooser(EncryptedFileChooser): #prompt_description = "Modify an LBRY File's options" def __init__(self, console, lbry_file_manager): - LBRYFileChooser.__init__(self, console, lbry_file_manager, ModifyLBRYFileOptionsFactory, lbry_file_manager) + EncryptedFileChooser.__init__(self, console, lbry_file_manager, ModifyEncryptedFileOptionsFactory, lbry_file_manager) -class ModifyLBRYFileOptionsChooserFactory(CommandHandlerFactory): - control_handler_class = ModifyLBRYFileOptionsChooser +class ModifyEncryptedFileOptionsChooserFactory(CommandHandlerFactory): + control_handler_class = ModifyEncryptedFileOptionsChooser command = "modify-lbryfile-options" short_help = "Modify an LBRY file's options" full_help = "Modify an LBRY file's options. Options include, and are limited to, " \ @@ -1435,7 +1435,7 @@ class ModifyLBRYFileOptionsChooserFactory(CommandHandlerFactory): "this LBRY file." -class ModifyLBRYFileOptions(RecursiveCommandHandler): +class ModifyEncryptedFileOptions(RecursiveCommandHandler): #prompt_description = "Modify an LBRY File's options" def __init__(self, console, lbry_file, lbry_file_manager): @@ -1445,12 +1445,12 @@ class ModifyLBRYFileOptions(RecursiveCommandHandler): def _get_control_handler_factories(self): factories = [] - factories.append(ModifyLBRYFileDataPaymentRateFactory(self.lbry_file, self.lbry_file_manager)) + factories.append(ModifyEncryptedFileDataPaymentRateFactory(self.lbry_file, self.lbry_file_manager)) return factories -class ModifyLBRYFileOptionsFactory(LBRYFileChooserFactory): - control_handler_class = ModifyLBRYFileOptions +class ModifyEncryptedFileOptionsFactory(EncryptedFileChooserFactory): + control_handler_class = ModifyEncryptedFileOptions class ClaimName(CommandHandler): @@ -1821,7 +1821,7 @@ class Publish(CommandHandler): def set_status(self, lbry_file_downloader): self.lbry_file = lbry_file_downloader d = self.lbry_file_manager.change_lbry_file_status(self.lbry_file, - ManagedLBRYFileDownloader.STATUS_FINISHED) + ManagedEncryptedFileDownloader.STATUS_FINISHED) d.addCallback(lambda _: lbry_file_downloader.restore()) return d @@ -2354,7 +2354,7 @@ class PeerStatsAndSettingsChooserFactory(CommandHandlerFactory): "which peers to connect to." -class LBRYFileStatusModifier(CommandHandler): +class EncryptedFileStatusModifier(CommandHandler): def __init__(self, console, lbry_file, stream_info_manager, blob_manager, lbry_file_manager): CommandHandler.__init__(self, console) self.lbry_file = lbry_file @@ -2371,11 +2371,11 @@ class LBRYFileStatusModifier(CommandHandler): if self.current_handler is None: if line: if line.lower() == 'd': - self.current_handler = DeleteLBRYFile(self.console, self.lbry_file, + self.current_handler = DeleteEncryptedFile(self.console, self.lbry_file, self.stream_info_manager, self.blob_manager, self.lbry_file_manager) elif line.lower() == 't': - self.current_handler = ToggleLBRYFileRunning(self.console, self.lbry_file, + self.current_handler = ToggleEncryptedFileRunning(self.console, self.lbry_file, self.lbry_file_manager) else: self.console.sendLine("Invalid selection\n") @@ -2444,7 +2444,7 @@ class Status(CommandHandler): self.console.sendLine("Invalid choice.\n") self.finished_deferred.callback(None) return - self.current_handler = LBRYFileStatusModifier(self.console, self.lbry_files[index], + self.current_handler = EncryptedFileStatusModifier(self.console, self.lbry_files[index], self.lbry_file_manager.stream_info_manager, self.blob_manager, self.lbry_file_manager) try: diff --git a/lbrynet/lbrynet_daemon/Daemon.py b/lbrynet/lbrynet_daemon/Daemon.py index cdcbbb47f..0c9829468 100644 --- a/lbrynet/lbrynet_daemon/Daemon.py +++ b/lbrynet/lbrynet_daemon/Daemon.py @@ -32,9 +32,9 @@ from lbrynet.core.server.BlobAvailabilityHandler import BlobAvailabilityHandlerF from lbrynet.core.server.BlobRequestHandler import BlobRequestHandlerFactory from lbrynet.core.server.ServerProtocol import ServerProtocolFactory from lbrynet.core.Error import UnknownNameError, InsufficientFundsError, InvalidNameError -from lbrynet.lbryfile.StreamDescriptor import LBRYFileStreamType -from lbrynet.lbryfile.client.LBRYFileDownloader import LBRYFileSaverFactory, LBRYFileOpenerFactory -from lbrynet.lbryfile.client.LBRYFileOptions import add_lbry_file_to_sd_identifier +from lbrynet.lbryfile.StreamDescriptor import EncryptedFileStreamType +from lbrynet.lbryfile.client.EncryptedFileDownloader import EncryptedFileSaverFactory, EncryptedFileOpenerFactory +from lbrynet.lbryfile.client.EncryptedFileOptions import add_lbry_file_to_sd_identifier from lbrynet.lbrynet_daemon.LBRYUIManager import LBRYUIManager from lbrynet.lbrynet_daemon.LBRYDownloader import GetStream from lbrynet.lbrynet_daemon.LBRYPublisher import Publisher @@ -55,8 +55,8 @@ from lbrynet.core.StreamDescriptor import StreamDescriptorIdentifier, download_s from lbrynet.core.Session import LBRYSession from lbrynet.core.PTCWallet import PTCWallet from lbrynet.core.LBRYWallet import LBRYcrdWallet, LBRYumWallet -from lbrynet.lbryfilemanager.LBRYFileManager import LBRYFileManager -from lbrynet.lbryfile.LBRYFileMetadataManager import DBLBRYFileMetadataManager, TempLBRYFileMetadataManager +from lbrynet.lbryfilemanager.EncryptedFileManager import EncryptedFileManager +from lbrynet.lbryfile.EncryptedFileMetadataManager import DBEncryptedFileMetadataManager, TempEncryptedFileMetadataManager from lbrynet import reflector @@ -379,7 +379,7 @@ class LBRYDaemon(jsonrpc.JSONRPC): # self.lbrynet_connection_checker = LoopingCall(self._check_lbrynet_connection) self.sd_identifier = StreamDescriptorIdentifier() - self.stream_info_manager = TempLBRYFileMetadataManager() + self.stream_info_manager = TempEncryptedFileMetadataManager() self.settings = LBRYSettings(self.db_dir) self.lbry_ui_manager = LBRYUIManager(root) self.blob_request_payment_rate_manager = None @@ -688,7 +688,7 @@ class LBRYDaemon(jsonrpc.JSONRPC): self._add_to_pending_claims(name, txid) def _process_lbry_file(name, lbry_file): - # lbry_file is an instance of ManagedLBRYFileDownloader or None + # lbry_file is an instance of ManagedEncryptedFileDownloader or None # TODO: check for sd_hash in addition to txid ready_to_start = ( lbry_file and @@ -1022,11 +1022,11 @@ class LBRYDaemon(jsonrpc.JSONRPC): def _setup_lbry_file_manager(self): self.startup_status = STARTUP_STAGES[3] - self.lbry_file_metadata_manager = DBLBRYFileMetadataManager(self.db_dir) + self.lbry_file_metadata_manager = DBEncryptedFileMetadataManager(self.db_dir) d = self.lbry_file_metadata_manager.setup() def set_lbry_file_manager(): - self.lbry_file_manager = LBRYFileManager(self.session, + self.lbry_file_manager = EncryptedFileManager(self.session, self.lbry_file_metadata_manager, self.sd_identifier, download_directory=self.download_directory) @@ -1087,22 +1087,22 @@ class LBRYDaemon(jsonrpc.JSONRPC): return dl def _setup_stream_identifier(self): - file_saver_factory = LBRYFileSaverFactory(self.session.peer_finder, self.session.rate_limiter, + file_saver_factory = EncryptedFileSaverFactory(self.session.peer_finder, self.session.rate_limiter, self.session.blob_manager, self.stream_info_manager, self.session.wallet, self.download_directory) - self.sd_identifier.add_stream_downloader_factory(LBRYFileStreamType, file_saver_factory) - file_opener_factory = LBRYFileOpenerFactory(self.session.peer_finder, self.session.rate_limiter, + self.sd_identifier.add_stream_downloader_factory(EncryptedFileStreamType, file_saver_factory) + file_opener_factory = EncryptedFileOpenerFactory(self.session.peer_finder, self.session.rate_limiter, self.session.blob_manager, self.stream_info_manager, self.session.wallet) - self.sd_identifier.add_stream_downloader_factory(LBRYFileStreamType, file_opener_factory) + self.sd_identifier.add_stream_downloader_factory(EncryptedFileStreamType, file_opener_factory) return defer.succeed(None) def _setup_lbry_file_opener(self): - downloader_factory = LBRYFileOpenerFactory(self.session.peer_finder, self.session.rate_limiter, + downloader_factory = EncryptedFileOpenerFactory(self.session.peer_finder, self.session.rate_limiter, self.session.blob_manager, self.stream_info_manager, self.session.wallet) - self.sd_identifier.add_stream_downloader_factory(LBRYFileStreamType, downloader_factory) + self.sd_identifier.add_stream_downloader_factory(EncryptedFileStreamType, downloader_factory) return defer.succeed(True) def _download_sd_blob(self, sd_hash, timeout=DEFAULT_SD_DOWNLOAD_TIMEOUT): diff --git a/lbrynet/lbrynet_daemon/DaemonServer.py b/lbrynet/lbrynet_daemon/DaemonServer.py index 79f6b038d..594f47b37 100644 --- a/lbrynet/lbrynet_daemon/DaemonServer.py +++ b/lbrynet/lbrynet_daemon/DaemonServer.py @@ -231,7 +231,7 @@ class LBRYindex(resource.Resource): return static.File(os.path.join(self.ui_dir, "index.html")).render_GET(request) -class LBRYFileStreamer(object): +class EncryptedFileStreamer(object): """ Writes downloaded LBRY file to request as the download comes in, pausing and resuming as requested used for Chrome @@ -315,13 +315,13 @@ class LBRYFileStreamer(object): return defer.succeed(None) -class HostedLBRYFile(resource.Resource): +class HostedEncryptedFile(resource.Resource): def __init__(self, api): self._api = api self._producer = None resource.Resource.__init__(self) - # todo: fix LBRYFileStreamer and use it instead of static.File + # todo: fix EncryptedFileStreamer and use it instead of static.File # def makeProducer(self, request, stream): # def _save_producer(producer): # self._producer = producer @@ -333,7 +333,7 @@ class HostedLBRYFile(resource.Resource): # path = os.path.join(self._api.download_directory, stream.file_name) # # d = stream.get_total_bytes() - # d.addCallback(lambda size: _save_producer(LBRYFileStreamer(request, path, start, stop, size))) + # d.addCallback(lambda size: _save_producer(EncryptedFileStreamer(request, path, start, stop, size))) # d.addCallback(lambda _: request.registerProducer(self._producer, streaming=True)) # # request.notifyFinish().addCallback(lambda _: self._producer.stopProducing()) # request.notifyFinish().addErrback(self._responseFailed, d) @@ -362,7 +362,7 @@ class HostedLBRYFile(resource.Resource): # call.addErrback(lambda err: log.info("Error: " + str(err))) # call.cancel() -class LBRYFileUpload(resource.Resource): +class EncryptedFileUpload(resource.Resource): """ Accepts a file sent via the file upload widget in the web UI, saves it into a temporary dir, and responds with a JSON string containing @@ -405,8 +405,8 @@ class LBRYDaemonServer(object): def _setup_server(self, wallet): self.root = LBRYindex(os.path.join(os.path.join(data_dir, "lbry-ui"), "active")) self._api = LBRYDaemon(self.root, wallet_type=wallet) - self.root.putChild("view", HostedLBRYFile(self._api)) - self.root.putChild("upload", LBRYFileUpload(self._api)) + self.root.putChild("view", HostedEncryptedFile(self._api)) + self.root.putChild("upload", EncryptedFileUpload(self._api)) self.root.putChild(API_ADDRESS, self._api) return defer.succeed(True) diff --git a/lbrynet/lbrynet_daemon/Downloader.py b/lbrynet/lbrynet_daemon/Downloader.py index cf7289354..c4bda5c67 100644 --- a/lbrynet/lbrynet_daemon/Downloader.py +++ b/lbrynet/lbrynet_daemon/Downloader.py @@ -12,7 +12,7 @@ from lbrynet.core.Error import InsufficientFundsError, KeyFeeAboveMaxAllowed from lbrynet.core.PaymentRateManager import PaymentRateManager from lbrynet.core.StreamDescriptor import download_sd_blob from lbrynet.metadata.LBRYFee import LBRYFeeValidator -from lbrynet.lbryfilemanager.LBRYFileDownloader import ManagedLBRYFileDownloaderFactory +from lbrynet.lbryfilemanager.EncryptedFileDownloader import ManagedEncryptedFileDownloaderFactory from lbrynet.conf import DEFAULT_TIMEOUT, LOG_FILE_NAME INITIALIZING_CODE = 'initializing' @@ -105,7 +105,7 @@ class GetStream(object): def get_downloader_factory(metadata): for factory in metadata.factories: - if isinstance(factory, ManagedLBRYFileDownloaderFactory): + if isinstance(factory, ManagedEncryptedFileDownloaderFactory): return factory, metadata raise Exception('No suitable factory was found in {}'.format(metadata.factories)) diff --git a/lbrynet/lbrynet_daemon/Publisher.py b/lbrynet/lbrynet_daemon/Publisher.py index f162ca24c..16e8c13c3 100644 --- a/lbrynet/lbrynet_daemon/Publisher.py +++ b/lbrynet/lbrynet_daemon/Publisher.py @@ -7,11 +7,11 @@ import random from appdirs import user_data_dir from lbrynet.core.Error import InsufficientFundsError -from lbrynet.lbryfilemanager.LBRYFileCreator import create_lbry_file +from lbrynet.lbryfilemanager.EncryptedFileCreator import create_lbry_file from lbrynet.lbryfile.StreamDescriptor import publish_sd_blob from lbrynet.core.PaymentRateManager import PaymentRateManager from lbrynet.metadata.LBRYMetadata import Metadata -from lbrynet.lbryfilemanager.LBRYFileDownloader import ManagedLBRYFileDownloader +from lbrynet.lbryfilemanager.EncryptedFileDownloader import ManagedEncryptedFileDownloader from lbrynet import reflector from lbrynet.conf import LOG_FILE_NAME, REFLECTOR_SERVERS from twisted.internet import threads, defer, reactor @@ -124,7 +124,7 @@ class Publisher(object): def set_status(self): log.debug('Setting status') - d = self.lbry_file_manager.change_lbry_file_status(self.lbry_file, ManagedLBRYFileDownloader.STATUS_FINISHED) + d = self.lbry_file_manager.change_lbry_file_status(self.lbry_file, ManagedEncryptedFileDownloader.STATUS_FINISHED) d.addCallback(lambda _: self.lbry_file.restore()) return d diff --git a/lbrynet/reflector/__init__.py b/lbrynet/reflector/__init__.py index d810cb10a..21885e442 100644 --- a/lbrynet/reflector/__init__.py +++ b/lbrynet/reflector/__init__.py @@ -1,3 +1,3 @@ from lbrynet.reflector.server.server import ReflectorServerFactory as ServerFactory -from lbrynet.reflector.client.client import LBRYFileReflectorClientFactory as ClientFactory +from lbrynet.reflector.client.client import EncryptedFileReflectorClientFactory as ClientFactory from lbrynet.reflector.client.client import LBRYBlobReflectorClientFactory as BlobClientFactory diff --git a/lbrynet/reflector/client/client.py b/lbrynet/reflector/client/client.py index 52ba3b271..12ee00551 100644 --- a/lbrynet/reflector/client/client.py +++ b/lbrynet/reflector/client/client.py @@ -61,7 +61,7 @@ class IncompleteResponseError(Exception): pass -class LBRYFileReflectorClient(Protocol): +class EncryptedFileReflectorClient(Protocol): # Protocol stuff @@ -238,8 +238,8 @@ class LBRYFileReflectorClient(Protocol): self.transport.loseConnection() -class LBRYFileReflectorClientFactory(ClientFactory): - protocol = LBRYFileReflectorClient +class EncryptedFileReflectorClientFactory(ClientFactory): + protocol = EncryptedFileReflectorClient def __init__(self, blob_manager, stream_info_manager, stream_hash): self.blob_manager = blob_manager