Remove duplicated legacy code for creating directories

This commit is contained in:
Zestyr 2017-06-18 06:48:12 +02:00
parent e0ff3171d8
commit 5db5d20f77
4 changed files with 3 additions and 36 deletions

View file

@ -64,7 +64,6 @@ class GetStream(object):
# fired after the metadata and the first data blob have been downloaded # fired after the metadata and the first data blob have been downloaded
self.data_downloading_deferred = defer.Deferred(None) self.data_downloading_deferred = defer.Deferred(None)
@property @property
def download_path(self): def download_path(self):
return os.path.join(self.download_directory, self.downloader.file_name) return os.path.join(self.download_directory, self.downloader.file_name)
@ -215,7 +214,6 @@ class GetStream(object):
safe_stop(self.checker) safe_stop(self.checker)
raise raise
try: try:
yield self.data_downloading_deferred yield self.data_downloading_deferred
except Exception as err: except Exception as err:
@ -224,4 +222,3 @@ class GetStream(object):
raise raise
defer.returnValue((self.downloader, self.finished_deferred)) defer.returnValue((self.downloader, self.finished_deferred))

View file

@ -1,24 +1,14 @@
import logging import logging
import os
import sys
import mimetypes import mimetypes
from appdirs import user_data_dir
from zope.interface import implements from zope.interface import implements
from twisted.internet import defer, error, interfaces, abstract, task, reactor from twisted.internet import defer, error, interfaces, abstract, task, reactor
# TODO: omg, this code is essentially duplicated in Daemon
if sys.platform != "darwin":
data_dir = os.path.join(os.path.expanduser("~"), ".lbrynet")
else:
data_dir = user_data_dir("LBRY")
if not os.path.isdir(data_dir):
os.mkdir(data_dir)
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
STATUS_FINISHED = 'finished' STATUS_FINISHED = 'finished'
class EncryptedFileStreamer(object): class EncryptedFileStreamer(object):
""" """
Writes LBRY stream to request; will pause to wait for new data if the file Writes LBRY stream to request; will pause to wait for new data if the file
@ -31,7 +21,6 @@ class EncryptedFileStreamer(object):
bufferSize = abstract.FileDescriptor.bufferSize bufferSize = abstract.FileDescriptor.bufferSize
# How long to wait between sending blocks (needed because some # How long to wait between sending blocks (needed because some
# video players freeze up if you try to send data too fast) # video players freeze up if you try to send data too fast)
stream_interval = 0.005 stream_interval = 0.005
@ -39,7 +28,6 @@ class EncryptedFileStreamer(object):
# How long to wait before checking if new data has been appended to the file # How long to wait before checking if new data has been appended to the file
new_data_check_interval = 0.25 new_data_check_interval = 0.25
def __init__(self, request, path, stream, file_manager): def __init__(self, request, path, stream, file_manager):
def _set_content_length_header(length): def _set_content_length_header(length):
self._request.setHeader('content-length', length) self._request.setHeader('content-length', length)

View file

@ -2,25 +2,15 @@ import logging
import os import os
import shutil import shutil
import json import json
import sys
import tempfile import tempfile
from appdirs import user_data_dir
from twisted.web import server, static, resource from twisted.web import server, static, resource
from twisted.internet import defer, error from twisted.internet import defer, error
from lbrynet import conf from lbrynet import conf
from lbrynet.lbrynet_daemon.FileStreamer import EncryptedFileStreamer from lbrynet.lbrynet_daemon.FileStreamer import EncryptedFileStreamer
# TODO: omg, this code is essentially duplicated in Daemon
if sys.platform != "darwin":
data_dir = os.path.join(os.path.expanduser("~"), ".lbrynet")
else:
data_dir = user_data_dir("LBRY")
if not os.path.isdir(data_dir):
os.mkdir(data_dir)
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -1,21 +1,13 @@
import json import json
import logging.handlers import logging.handlers
import sys
import os import os
from appdirs import user_data_dir
from twisted.internet.task import LoopingCall from twisted.internet.task import LoopingCall
from twisted.internet import reactor from twisted.internet import reactor
from lbrynet import conf
if sys.platform != "darwin": log_dir = conf.settings['data_dir']
log_dir = os.path.join(os.path.expanduser("~"), ".lbrynet")
else:
log_dir = user_data_dir("LBRY")
if not os.path.isdir(log_dir):
os.mkdir(log_dir)
LOG_FILENAME = os.path.join(log_dir, 'lbrynet-daemon.log') LOG_FILENAME = os.path.join(log_dir, 'lbrynet-daemon.log')
if os.path.isfile(LOG_FILENAME): if os.path.isfile(LOG_FILENAME):