parent
10c571b153
commit
c94b9d5fd2
@ -8,9 +8,14 @@ This changelog is used to track all major changes to Mopidy.
|
||||
v2.2.2 (UNRELEASED)
|
||||
===================
|
||||
|
||||
Bug fix release.
|
||||
|
||||
- HTTP: Fix hang on exit due to change in Tornado v5.0 IOLoop. (Fixes:
|
||||
:issue:`1715`, PR: :issue:`1716`)
|
||||
|
||||
- Files: Fix crash due to mix of text and bytes in paths that come from
|
||||
``$XDG_CONFIG_HOME/user-dirs.dirs``. (Fixes: :issue:`1676`, :issue:`1725`)
|
||||
|
||||
|
||||
v2.2.1 (2018-10-15)
|
||||
===================
|
||||
|
||||
@ -53,15 +53,16 @@ def _get_user_dirs(xdg_config_dir):
|
||||
return {}
|
||||
|
||||
with open(dirs_file, 'rb') as fh:
|
||||
data = fh.read().decode('utf-8')
|
||||
data = fh.read()
|
||||
|
||||
data = '[XDG_USER_DIRS]\n' + data
|
||||
data = data.replace('$HOME', os.path.expanduser('~'))
|
||||
data = data.replace('"', '')
|
||||
data = b'[XDG_USER_DIRS]\n' + data
|
||||
data = data.replace(b'$HOME', os.path.expanduser(b'~'))
|
||||
data = data.replace(b'"', b'')
|
||||
|
||||
config = configparser.RawConfigParser()
|
||||
config.readfp(io.StringIO(data))
|
||||
config.readfp(io.BytesIO(data))
|
||||
|
||||
return {
|
||||
k.upper(): os.path.abspath(v)
|
||||
for k, v in config.items('XDG_USER_DIRS') if v is not None}
|
||||
k.upper().decode('utf-8'): os.path.abspath(v)
|
||||
for k, v in config.items('XDG_USER_DIRS') if v is not None
|
||||
}
|
||||
|
||||
@ -21,9 +21,10 @@ def test_cache_dir_default(environ):
|
||||
|
||||
|
||||
def test_cache_dir_from_env(environ):
|
||||
os.environ['XDG_CACHE_HOME'] = '/foo/bar'
|
||||
os.environ['XDG_CACHE_HOME'] = b'/foo/bar'
|
||||
|
||||
assert xdg.get_dirs()['XDG_CACHE_DIR'] == '/foo/bar'
|
||||
assert xdg.get_dirs()['XDG_CACHE_DIR'] == b'/foo/bar'
|
||||
assert type(xdg.get_dirs()['XDG_CACHE_DIR']) == bytes
|
||||
|
||||
|
||||
def test_config_dir_default(environ):
|
||||
@ -31,9 +32,10 @@ def test_config_dir_default(environ):
|
||||
|
||||
|
||||
def test_config_dir_from_env(environ):
|
||||
os.environ['XDG_CONFIG_HOME'] = '/foo/bar'
|
||||
os.environ['XDG_CONFIG_HOME'] = b'/foo/bar'
|
||||
|
||||
assert xdg.get_dirs()['XDG_CONFIG_DIR'] == '/foo/bar'
|
||||
assert xdg.get_dirs()['XDG_CONFIG_DIR'] == b'/foo/bar'
|
||||
assert type(xdg.get_dirs()['XDG_CONFIG_DIR']) == bytes
|
||||
|
||||
|
||||
def test_data_dir_default(environ):
|
||||
@ -42,21 +44,23 @@ def test_data_dir_default(environ):
|
||||
|
||||
|
||||
def test_data_dir_from_env(environ):
|
||||
os.environ['XDG_DATA_HOME'] = '/foo/bar'
|
||||
os.environ['XDG_DATA_HOME'] = b'/foo/bar'
|
||||
|
||||
assert xdg.get_dirs()['XDG_DATA_DIR'] == '/foo/bar'
|
||||
assert xdg.get_dirs()['XDG_DATA_DIR'] == b'/foo/bar'
|
||||
assert type(xdg.get_dirs()['XDG_DATA_DIR']) == bytes
|
||||
|
||||
|
||||
def test_user_dirs(environ, tmpdir):
|
||||
os.environ['XDG_CONFIG_HOME'] = str(tmpdir)
|
||||
|
||||
with open(os.path.join(str(tmpdir), 'user-dirs.dirs'), 'wb') as fh:
|
||||
fh.write('# Some comments\n')
|
||||
fh.write('XDG_MUSIC_DIR="$HOME/Music2"\n')
|
||||
fh.write(b'# Some comments\n')
|
||||
fh.write(b'XDG_MUSIC_DIR="$HOME/Music2"\n')
|
||||
|
||||
result = xdg.get_dirs()
|
||||
|
||||
assert result['XDG_MUSIC_DIR'] == os.path.expanduser(b'~/Music2')
|
||||
assert type(result['XDG_MUSIC_DIR']) == bytes
|
||||
assert 'XDG_DOWNLOAD_DIR' not in result
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user