parent
a2350fd539
commit
bfa626c6e6
2 changed files with 80 additions and 22 deletions
|
@ -15,13 +15,16 @@ at anytime.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
* claim_show API command no longer takes name as argument
|
* claim_show API command no longer takes name as argument
|
||||||
*
|
* 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`
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
* Fix for https://github.com/lbryio/lbry/issues/750
|
* Fix for https://github.com/lbryio/lbry/issues/750
|
||||||
* Fixed inconsistencies in claim_show output
|
* Fixed inconsistencies in claim_show output
|
||||||
* Fixed daemon process hanging when started without an internet connection
|
* Fixed daemon process hanging when started without an internet connection
|
||||||
* Fixed https://github.com/lbryio/lbry/issues/774
|
* Fixed https://github.com/lbryio/lbry/issues/774
|
||||||
|
* Fix XDG compliance on Linux
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
*
|
*
|
||||||
|
|
|
@ -2,12 +2,18 @@ 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
|
from appdirs import user_data_dir, user_config_dir
|
||||||
from lbrynet.core import utils
|
from lbrynet.core import utils
|
||||||
|
|
||||||
|
try:
|
||||||
|
from lbrynet.winhelpers.knownpaths import get_path, FOLDERID, UserHandle
|
||||||
|
except (ImportError, ValueError):
|
||||||
|
pass
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
@ -43,6 +49,7 @@ settings_encoders = {
|
||||||
'.yml': yaml.safe_dump
|
'.yml': yaml.safe_dump
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def _win_path_to_bytes(path):
|
def _win_path_to_bytes(path):
|
||||||
"""
|
"""
|
||||||
Encode Windows paths to string. appdirs.user_data_dir()
|
Encode Windows paths to string. appdirs.user_data_dir()
|
||||||
|
@ -58,29 +65,77 @@ def _win_path_to_bytes(path):
|
||||||
pass
|
pass
|
||||||
return path
|
return path
|
||||||
|
|
||||||
if sys.platform.startswith('darwin'):
|
|
||||||
|
def _get_old_directories(platform):
|
||||||
|
dirs = {}
|
||||||
|
if platform == WINDOWS:
|
||||||
|
appdata = get_path(FOLDERID.RoamingAppData, UserHandle.current)
|
||||||
|
dirs['data'] = os.path.join(appdata, 'lbrynet')
|
||||||
|
dirs['lbryum'] = os.path.join(appdata, 'lbryum')
|
||||||
|
dirs['download'] = get_path(FOLDERID.Downloads, UserHandle.current)
|
||||||
|
elif platform == DARWIN:
|
||||||
|
dirs['data'] = user_data_dir('LBRY')
|
||||||
|
dirs['lbryum'] = os.path.expanduser('~/.lbryum')
|
||||||
|
dirs['download'] = os.path.expanduser('~/Downloads')
|
||||||
|
elif platform == LINUX:
|
||||||
|
dirs['data'] = os.path.join(os.path.expanduser('~'), '~/.lbrynet')
|
||||||
|
dirs['lbryum'] = os.path.join(os.path.expanduser('~'), '~/.lbryum')
|
||||||
|
dirs['download'] = os.path.join(os.path.expanduser('~'), 'Downloads')
|
||||||
|
else:
|
||||||
|
raise ValueError('unknown platform value')
|
||||||
|
return dirs
|
||||||
|
|
||||||
|
|
||||||
|
def _get_new_directories(platform):
|
||||||
|
dirs = {}
|
||||||
|
if platform == WINDOWS:
|
||||||
|
dirs['data'] = user_data_dir('lbrynet', 'lbry')
|
||||||
|
dirs['lbryum'] = user_data_dir('lbryum', 'lbry')
|
||||||
|
dirs['download'] = get_path(FOLDERID.Downloads, UserHandle.current)
|
||||||
|
elif platform == DARWIN:
|
||||||
|
_get_old_directories(platform)
|
||||||
|
elif platform == LINUX:
|
||||||
|
dirs['data'] = user_data_dir('lbry/lbrynet')
|
||||||
|
dirs['lbryum'] = 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)
|
||||||
|
dirs['download'] = re.sub('\"', '', down_dir)
|
||||||
|
except EnvironmentError:
|
||||||
|
dirs['download'] = os.getenv('XDG_DOWNLOAD_DIR')
|
||||||
|
|
||||||
|
if not dirs['download']:
|
||||||
|
dirs['download'] = os.path.expanduser('~/Downloads')
|
||||||
|
else:
|
||||||
|
raise ValueError('unknown platform value')
|
||||||
|
return dirs
|
||||||
|
|
||||||
|
|
||||||
|
if 'darwin' in sys.platform:
|
||||||
platform = DARWIN
|
platform = DARWIN
|
||||||
default_download_directory = os.path.join(os.path.expanduser('~'), 'Downloads')
|
dirs = _get_old_directories(DARWIN)
|
||||||
default_data_dir = user_data_dir('LBRY')
|
elif 'win' in sys.platform:
|
||||||
default_lbryum_dir = os.path.join(os.path.expanduser('~'), '.lbryum')
|
|
||||||
elif sys.platform.startswith('win'):
|
|
||||||
platform = WINDOWS
|
platform = WINDOWS
|
||||||
from lbrynet.winhelpers.knownpaths import get_path, FOLDERID, UserHandle
|
if os.path.isdir(_get_old_directories(WINDOWS)['data']) or \
|
||||||
|
os.path.isdir(_get_old_directories(WINDOWS)['lbryum']):
|
||||||
default_download_directory = get_path(FOLDERID.Downloads, UserHandle.current)
|
dirs = _get_old_directories(WINDOWS)
|
||||||
default_data_dir = os.path.join(
|
else:
|
||||||
get_path(FOLDERID.RoamingAppData, UserHandle.current), 'lbrynet')
|
dirs = _get_new_directories(WINDOWS)
|
||||||
default_lbryum_dir = os.path.join(
|
dirs['data'] = _win_path_to_bytes(dirs['data'])
|
||||||
get_path(FOLDERID.RoamingAppData, UserHandle.current), 'lbryum')
|
dirs['lbryum'] = _win_path_to_bytes(dirs['lbryum'])
|
||||||
|
dirs['download'] = _win_path_to_bytes(dirs['download'])
|
||||||
default_download_directory = _win_path_to_bytes(default_download_directory)
|
|
||||||
default_data_dir = _win_path_to_bytes(default_data_dir)
|
|
||||||
default_lbryum_dir = _win_path_to_bytes(default_lbryum_dir)
|
|
||||||
else:
|
else:
|
||||||
platform = LINUX
|
platform = LINUX
|
||||||
default_download_directory = os.path.join(os.path.expanduser('~'), 'Downloads')
|
if os.path.isdir(_get_old_directories(LINUX)['data']) or \
|
||||||
default_data_dir = os.path.join(os.path.expanduser('~'), '.lbrynet')
|
os.path.isdir(_get_old_directories(LINUX)['lbryum']):
|
||||||
default_lbryum_dir = os.path.join(os.path.expanduser('~'), '.lbryum')
|
dirs = _get_old_directories(LINUX)
|
||||||
|
else:
|
||||||
|
dirs = _get_new_directories(LINUX)
|
||||||
|
|
||||||
|
default_data_dir = dirs['data']
|
||||||
|
default_lbryum_dir = dirs['lbryum']
|
||||||
|
default_download_dir = dirs['download']
|
||||||
|
|
||||||
ICON_PATH = 'icons' if platform is WINDOWS else 'app.icns'
|
ICON_PATH = 'icons' if platform is WINDOWS else 'app.icns'
|
||||||
|
|
||||||
|
@ -178,7 +233,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_directory),
|
'download_directory': (str, default_download_dir),
|
||||||
'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),
|
||||||
|
|
Loading…
Add table
Reference in a new issue