Revert "Fix default directories (fixes #574)"

This commit is contained in:
Umpei Kay Kurokawa 2017-07-03 11:09:59 -04:00 committed by GitHub
parent 1bf4048c46
commit 4e42ae97ea
6 changed files with 50 additions and 46 deletions

View file

@ -15,9 +15,6 @@ at anytime.
### Changed
* Change `max_key_fee` setting to be a dictionary with values for `currency` and `amount`
* Linux default downloads folder changed from `~/Downloads` to `XDG_DOWNLOAD_DIR`
* Linux folders moved from the home directory to `~/.local/share/lbry`
* Windows folders moved from `%APPDATA%/Roaming` to `%APPDATA%/Local/lbry`
* Renamed `lbrynet.lbryfile` to `lbrynet.lbry_file`
* Renamed `lbrynet.lbryfilemanager` to `lbrynet.file_manager`
* Renamed `lbrynet.lbrynet_daemon` to `lbrynet.daemon`
@ -29,7 +26,6 @@ at anytime.
* Fixed some log messages throwing exceptions
* Fix shutdown of the blob tracker by Session
* Fixed claim_new_support docstrings
* Fix default directories to comply to XDG
* Fixed BlobManager causing functional tests to fail, removed its unneeded manage() loop
* Increased max_key_fee

View file

@ -2,11 +2,10 @@ import base58
import json
import logging
import os
import re
import sys
import yaml
import envparse
from appdirs import user_data_dir, user_config_dir
from appdirs import user_data_dir
from lbrynet.core import utils
log = logging.getLogger(__name__)
@ -44,48 +43,25 @@ settings_encoders = {
'.yml': yaml.safe_dump
}
if 'darwin' in sys.platform:
if sys.platform.startswith('darwin'):
platform = DARWIN
default_download_dir = os.path.expanduser('~/Downloads')
default_download_directory = os.path.join(os.path.expanduser('~'), 'Downloads')
default_data_dir = user_data_dir('LBRY')
default_lbryum_dir = os.path.expanduser('~/.lbryum')
elif 'nt' in sys.platform:
default_lbryum_dir = os.path.join(os.path.expanduser('~'), '.lbryum')
elif sys.platform.startswith('win'):
platform = WINDOWS
from lbrynet.winhelpers.knownpaths import get_path, FOLDERID, UserHandle
default_download_dir = get_path(FOLDERID.Downloads, UserHandle.current)
# This checks whether the folders are still in their old locations
if os.path.isdir(user_data_dir('lbryum', roaming=True)) and \
os.path.isdir(user_data_dir('lbrynet', roaming=True)):
default_data_dir = user_data_dir('lbrynet', roaming=True)
default_lbryum_dir = user_data_dir('lbryum', roaming=True)
else:
default_data_dir = user_data_dir('lbrynet', 'lbry')
default_lbryum_dir = user_data_dir('lbryum', 'lbry')
default_download_directory = get_path(FOLDERID.Downloads, UserHandle.current)
default_data_dir = os.path.join(
get_path(FOLDERID.RoamingAppData, UserHandle.current), 'lbrynet')
default_lbryum_dir = os.path.join(
get_path(FOLDERID.RoamingAppData, UserHandle.current), 'lbryum')
else:
platform = LINUX
# This checks whether the folders are still in their old locations
if os.path.isdir(os.path.expanduser('~/.lbrynet')) and \
os.path.isdir(os.path.expanduser('~/.lbryum')):
default_data_dir = os.path.expanduser('~/.lbrynet')
default_lbryum_dir = os.path.expanduser('~/.lbryum')
default_download_dir = os.path.expanduser('~/Downloads')
else:
default_data_dir = user_data_dir('lbry/lbrynet')
default_lbryum_dir = user_data_dir('lbry/lbryum')
try:
with open(os.path.join(user_config_dir(), 'user-dirs.dirs'), 'r') as xdg:
down_dir = re.search(r'XDG_DOWNLOAD_DIR=(.+)', xdg.read()).group(1)
down_dir = re.sub('\$HOME', os.getenv('HOME'), down_dir)
default_download_dir = re.sub('\"', '', down_dir)
except EnvironmentError:
default_download_dir = os.getenv('XDG_DOWNLOAD_DIR')
if not default_download_dir:
default_download_dir = os.path.expanduser('~/Downloads')
default_download_directory = os.path.join(os.path.expanduser('~'), 'Downloads')
default_data_dir = os.path.join(os.path.expanduser('~'), '.lbrynet')
default_lbryum_dir = os.path.join(os.path.expanduser('~'), '.lbryum')
ICON_PATH = 'icons' if platform is WINDOWS else 'app.icns'
@ -183,7 +159,7 @@ ADJUSTABLE_SETTINGS = {
'data_rate': (float, .0001), # points/megabyte
'delete_blobs_on_remove': (bool, True),
'dht_node_port': (int, 4444),
'download_directory': (str, default_download_dir),
'download_directory': (str, default_download_directory),
'download_timeout': (int, 180),
'is_generous_host': (bool, True),
'known_dht_nodes': (list, DEFAULT_DHT_NODES, server_port),

View file

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

View file

@ -1,14 +1,24 @@
import logging
import os
import sys
import mimetypes
from appdirs import user_data_dir
from zope.interface import implements
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__)
STATUS_FINISHED = 'finished'
class EncryptedFileStreamer(object):
"""
Writes LBRY stream to request; will pause to wait for new data if the file
@ -21,6 +31,7 @@ class EncryptedFileStreamer(object):
bufferSize = abstract.FileDescriptor.bufferSize
# How long to wait between sending blocks (needed because some
# video players freeze up if you try to send data too fast)
stream_interval = 0.005
@ -28,6 +39,7 @@ class EncryptedFileStreamer(object):
# How long to wait before checking if new data has been appended to the file
new_data_check_interval = 0.25
def __init__(self, request, path, stream, file_manager):
def _set_content_length_header(length):
self._request.setHeader('content-length', length)

View file

@ -2,15 +2,25 @@ import logging
import os
import shutil
import json
import sys
import tempfile
from appdirs import user_data_dir
from twisted.web import server, static, resource
from twisted.internet import defer, error
from lbrynet import conf
from 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__)

View file

@ -1,14 +1,21 @@
import json
import logging.handlers
import sys
import os
from appdirs import user_data_dir
from twisted.internet.task import LoopingCall
from twisted.internet import reactor
from lbrynet import conf
conf.initialize_settings()
log_dir = conf.settings['data_dir']
if sys.platform != "darwin":
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')
if os.path.isfile(LOG_FILENAME):