From 4919cae889072dbf4ec5fd94dabbee17c198dd78 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Fri, 20 Jun 2014 00:25:34 +0200 Subject: [PATCH] local: Add friendly help if no local library cache found Fixes #711 --- docs/changelog.rst | 4 ++++ mopidy/local/json.py | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 1708e98c..646fed65 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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. diff --git a/mopidy/local/json.py b/mopidy/local/json.py index a8997367..927f8898 100644 --- a/mopidy/local/json.py +++ b/mopidy/local/json.py @@ -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)