forked from LBRYCommunity/lbry-sdk
Revert "Fix default directories (fixes #574)"
This commit is contained in:
parent
1bf4048c46
commit
4e42ae97ea
6 changed files with 50 additions and 46 deletions
|
@ -15,9 +15,6 @@ at anytime.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
* Change `max_key_fee` setting to be a dictionary with values for `currency` and `amount`
|
* 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.lbryfile` to `lbrynet.lbry_file`
|
||||||
* Renamed `lbrynet.lbryfilemanager` to `lbrynet.file_manager`
|
* Renamed `lbrynet.lbryfilemanager` to `lbrynet.file_manager`
|
||||||
* Renamed `lbrynet.lbrynet_daemon` to `lbrynet.daemon`
|
* Renamed `lbrynet.lbrynet_daemon` to `lbrynet.daemon`
|
||||||
|
@ -29,7 +26,6 @@ at anytime.
|
||||||
* Fixed some log messages throwing exceptions
|
* Fixed some log messages throwing exceptions
|
||||||
* Fix shutdown of the blob tracker by Session
|
* Fix shutdown of the blob tracker by Session
|
||||||
* Fixed claim_new_support docstrings
|
* Fixed claim_new_support docstrings
|
||||||
* Fix default directories to comply to XDG
|
|
||||||
* Fixed BlobManager causing functional tests to fail, removed its unneeded manage() loop
|
* Fixed BlobManager causing functional tests to fail, removed its unneeded manage() loop
|
||||||
* Increased max_key_fee
|
* Increased max_key_fee
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,10 @@ import base58
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
import sys
|
import sys
|
||||||
import yaml
|
import yaml
|
||||||
import envparse
|
import envparse
|
||||||
from appdirs import user_data_dir, user_config_dir
|
from appdirs import user_data_dir
|
||||||
from lbrynet.core import utils
|
from lbrynet.core import utils
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -44,48 +43,25 @@ settings_encoders = {
|
||||||
'.yml': yaml.safe_dump
|
'.yml': yaml.safe_dump
|
||||||
}
|
}
|
||||||
|
|
||||||
if 'darwin' in sys.platform:
|
if sys.platform.startswith('darwin'):
|
||||||
platform = 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_data_dir = user_data_dir('LBRY')
|
||||||
default_lbryum_dir = os.path.expanduser('~/.lbryum')
|
default_lbryum_dir = os.path.join(os.path.expanduser('~'), '.lbryum')
|
||||||
elif 'nt' in sys.platform:
|
elif sys.platform.startswith('win'):
|
||||||
platform = WINDOWS
|
platform = WINDOWS
|
||||||
from lbrynet.winhelpers.knownpaths import get_path, FOLDERID, UserHandle
|
from lbrynet.winhelpers.knownpaths import get_path, FOLDERID, UserHandle
|
||||||
|
|
||||||
default_download_dir = get_path(FOLDERID.Downloads, UserHandle.current)
|
default_download_directory = get_path(FOLDERID.Downloads, UserHandle.current)
|
||||||
|
default_data_dir = os.path.join(
|
||||||
# This checks whether the folders are still in their old locations
|
get_path(FOLDERID.RoamingAppData, UserHandle.current), 'lbrynet')
|
||||||
if os.path.isdir(user_data_dir('lbryum', roaming=True)) and \
|
default_lbryum_dir = os.path.join(
|
||||||
os.path.isdir(user_data_dir('lbrynet', roaming=True)):
|
get_path(FOLDERID.RoamingAppData, UserHandle.current), 'lbryum')
|
||||||
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')
|
|
||||||
else:
|
else:
|
||||||
platform = LINUX
|
platform = LINUX
|
||||||
|
default_download_directory = os.path.join(os.path.expanduser('~'), 'Downloads')
|
||||||
# This checks whether the folders are still in their old locations
|
default_data_dir = os.path.join(os.path.expanduser('~'), '.lbrynet')
|
||||||
if os.path.isdir(os.path.expanduser('~/.lbrynet')) and \
|
default_lbryum_dir = os.path.join(os.path.expanduser('~'), '.lbryum')
|
||||||
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')
|
|
||||||
|
|
||||||
|
|
||||||
ICON_PATH = 'icons' if platform is WINDOWS else 'app.icns'
|
ICON_PATH = 'icons' if platform is WINDOWS else 'app.icns'
|
||||||
|
|
||||||
|
@ -183,7 +159,7 @@ ADJUSTABLE_SETTINGS = {
|
||||||
'data_rate': (float, .0001), # points/megabyte
|
'data_rate': (float, .0001), # points/megabyte
|
||||||
'delete_blobs_on_remove': (bool, True),
|
'delete_blobs_on_remove': (bool, True),
|
||||||
'dht_node_port': (int, 4444),
|
'dht_node_port': (int, 4444),
|
||||||
'download_directory': (str, default_download_dir),
|
'download_directory': (str, default_download_directory),
|
||||||
'download_timeout': (int, 180),
|
'download_timeout': (int, 180),
|
||||||
'is_generous_host': (bool, True),
|
'is_generous_host': (bool, True),
|
||||||
'known_dht_nodes': (list, DEFAULT_DHT_NODES, server_port),
|
'known_dht_nodes': (list, DEFAULT_DHT_NODES, server_port),
|
||||||
|
|
|
@ -64,6 +64,7 @@ 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)
|
||||||
|
@ -214,6 +215,7 @@ 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:
|
||||||
|
@ -222,3 +224,4 @@ class GetStream(object):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
defer.returnValue((self.downloader, self.finished_deferred))
|
defer.returnValue((self.downloader, self.finished_deferred))
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,24 @@
|
||||||
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
|
||||||
|
@ -21,6 +31,7 @@ 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
|
||||||
|
@ -28,6 +39,7 @@ 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)
|
||||||
|
|
|
@ -2,15 +2,25 @@ 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.daemon.FileStreamer import EncryptedFileStreamer
|
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__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,21 @@
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
conf.initialize_settings()
|
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):
|
||||||
|
|
Loading…
Add table
Reference in a new issue