local: Add friendly help if no local library cache found

Fixes #711
This commit is contained in:
Stein Magnus Jodal 2014-06-20 00:25:34 +02:00
parent 5c726c3228
commit 4919cae889
2 changed files with 12 additions and 0 deletions

View File

@ -121,6 +121,10 @@ Feature release.
**Local backend**
- The JSON local library backend now logs a friendly message telling you about
``mopidy local scan`` if you don't have a local library cache. (Fixes:
:issue:`711`)
- The ``local scan`` command now use multiple threads to walk the file system
and check files' modification time. This speeds up scanning, escpecially
when scanning remote file systems over e.g. NFS.

View File

@ -20,6 +20,14 @@ logger = logging.getLogger(__name__)
# TODO: move to load and dump in models?
def load_library(json_file):
if not os.path.isfile(json_file):
logger.info(
'No local library metadata cache found at %s. Please run '
'`mopidy local scan` to index your local music library. '
'If you do not have a local music collection, you can disable the '
'local backend to hide this message.',
json_file)
return {}
try:
with gzip.open(json_file, 'rb') as fp:
return json.load(fp, object_hook=models.model_json_decoder)