mopidy / mopidy-local-sqlite

DEPRECATED (Mopidy SQLite local library extension)
https://mopidy.com
Apache License 2.0
30 stars 10 forks source link

Improve handling of file system encoding errors #41

Closed tkem closed 9 years ago

tkem commented 9 years ago

Currently, if a directory path cannot be decoded when browsing "Folders", an exception is raised, and the parent folder will appear to be empty. This is usually the case when mopidy is running with the "POSIX" locale, i.e. an incomplete/erroneous locale setup (such as on Pi MusicBox RC5.1). It might be better to follow the json library, and explicitly decode directory paths (and probably track names) using sys.getfilesystemencoding() with errors=replace. Note that this will not automagically provide support for Unicode directory paths, but will result in less cryptic behavior (i.e. users who see non-ASCII characters replaced with something funny are more likely to look into locale and filesystem settings).

jodal commented 9 years ago

:+1:

tkem commented 9 years ago

See also https://discuss.mopidy.com/t/network-folders-are-showing-up-empty-in-musicbox-0-5-1rc/315

tkem commented 9 years ago

The exception is actually raised in sorted(os.listdir(...)), since os.listdir returns byte strings on Python 2 if the file name cannot be decoded, and sorted tries to decode using ascii for mixed string sequences. Or so it seems.