From 1ffb99f9f9a40b7dd767d004399b325649ec6031 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Wed, 24 Apr 2019 12:44:12 -0400 Subject: [PATCH] rename streaming_only setting -> save_files --- example_daemon_settings.yml | 2 +- lbrynet/conf.py | 2 +- lbrynet/extras/daemon/Daemon.py | 2 +- lbrynet/stream/stream_manager.py | 6 +++--- tests/integration/test_streaming.py | 13 ++++++------- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/example_daemon_settings.yml b/example_daemon_settings.yml index b18592859..d3dd1224f 100644 --- a/example_daemon_settings.yml +++ b/example_daemon_settings.yml @@ -13,7 +13,7 @@ data_dir: /home/lbry/.lbrynet download_directory: /home/lbry/downloads save_blobs: true -streaming_only: false +save_files: false dht_node_port: 4444 peer_port: 3333 use_upnp: true diff --git a/lbrynet/conf.py b/lbrynet/conf.py index a34164ff1..0e80ed74a 100644 --- a/lbrynet/conf.py +++ b/lbrynet/conf.py @@ -539,7 +539,7 @@ class Config(CLIConfig): cache_time = Integer("Time to cache resolved claims", 150) # TODO: use this # daemon - streaming_only = Toggle("Only stream downloaded files, do not write files to the downloads directory", False) + save_files = Toggle("Save downloaded files when calling `get` by default", True) components_to_skip = Strings("components which will be skipped during start-up of daemon", []) share_usage_data = Toggle( "Whether to share usage stats and diagnostic info with LBRY.", True, diff --git a/lbrynet/extras/daemon/Daemon.py b/lbrynet/extras/daemon/Daemon.py index 166fec905..0a48e9dc3 100644 --- a/lbrynet/extras/daemon/Daemon.py +++ b/lbrynet/extras/daemon/Daemon.py @@ -913,7 +913,7 @@ class Daemon(metaclass=JSONRPCServerType): Returns: {File} """ - save_file = save_file if save_file is not None else not self.conf.streaming_only + save_file = save_file if save_file is not None else self.conf.save_files try: stream = await self.stream_manager.download_stream_from_uri( uri, self.exchange_rate_manager, timeout, file_name, save_file=save_file diff --git a/lbrynet/stream/stream_manager.py b/lbrynet/stream/stream_manager.py index 93a33a062..6aeb13f6b 100644 --- a/lbrynet/stream/stream_manager.py +++ b/lbrynet/stream/stream_manager.py @@ -92,7 +92,7 @@ class StreamManager: async def start_stream(self, stream: ManagedStream): stream.update_status(ManagedStream.STATUS_RUNNING) await self.storage.change_file_status(stream.stream_hash, ManagedStream.STATUS_RUNNING) - await stream.setup(self.node, save_file=not self.config.streaming_only) + await stream.setup(self.node, save_file=self.config.save_files) self.storage.content_claim_callbacks[stream.stream_hash] = lambda: self._update_content_claim(stream) async def recover_streams(self, file_infos: typing.List[typing.Dict]): @@ -149,7 +149,7 @@ class StreamManager: # log.info("Attempting to recover %i streams", len(to_recover)) await self.recover_streams(to_recover) - if self.config.streaming_only: + if not self.config.save_files: to_set_as_streaming = [] for file_info in to_start: file_name = path_or_none(file_info['file_name']) @@ -381,7 +381,7 @@ class StreamManager: log.info("paid fee of %s for %s", fee_amount, uri) download_directory = download_directory or self.config.download_dir - if not file_name and (self.config.streaming_only or not save_file): + if not file_name and (not self.config.save_files or not save_file): download_dir, file_name = None, None stream = ManagedStream( self.loop, self.config, self.blob_manager, claim.stream.source.sd_hash, download_directory, diff --git a/tests/integration/test_streaming.py b/tests/integration/test_streaming.py index b0e786481..1c4bdc8df 100644 --- a/tests/integration/test_streaming.py +++ b/tests/integration/test_streaming.py @@ -1,6 +1,5 @@ import os import hashlib -import asyncio import aiohttp import aiohttp.web @@ -25,9 +24,9 @@ class RangeRequests(CommandTestCase): await self.daemon.stream_manager.start() return - async def _setup_stream(self, data: bytes, save_blobs: bool = True, streaming_only: bool = True): + async def _setup_stream(self, data: bytes, save_blobs: bool = True, save_files: bool = False): self.daemon.conf.save_blobs = save_blobs - self.daemon.conf.streaming_only = streaming_only + self.daemon.conf.save_files = save_files self.data = data await self.stream_create('foo', '0.01', data=self.data) if save_blobs: @@ -192,9 +191,9 @@ class RangeRequests(CommandTestCase): len(files_in_download_dir), len(current_files_in_download_dir) ) - async def test_stream_and_save_with_blobs(self): + async def test_stream_and_save_file_with_blobs(self): self.data = get_random_bytes((MAX_BLOB_SIZE - 1) * 4) - await self._setup_stream(self.data, streaming_only=False) + await self._setup_stream(self.data, save_files=True) await self._test_range_requests() streams = self.daemon.jsonrpc_file_list() @@ -246,9 +245,9 @@ class RangeRequests(CommandTestCase): with open(stream.full_path, 'rb') as f: self.assertEqual(self.data, f.read()) - async def test_stream_and_save_without_blobs(self): + async def test_stream_and_save_file_without_blobs(self): self.data = get_random_bytes((MAX_BLOB_SIZE - 1) * 4) - await self._setup_stream(self.data, streaming_only=False) + await self._setup_stream(self.data, save_files=True) self.daemon.conf.save_blobs = False await self._test_range_requests()