Exit with error if clear or scan attempts to load nonexistent library
Fixes #1298 (cherry picked from commit 1e037adfc1fbecaebcd6173a2bcda7ce6d436c37) (cherry picked from commit 44eb668ff957fae42d3ddcab9a3acda56d9ecc8c) (cherry picked from commit bf318fb1ea09108d9b0c32de2d70383f9f740c4b)
This commit is contained in:
parent
b020d12885
commit
525019d03e
@ -14,6 +14,9 @@ Bug fix release.
|
||||
example Ogg Vorbis has the MIME type ``application/ogg``. (Fixes:
|
||||
:issue:`1299`)
|
||||
|
||||
- Local: If the scan or clear commands are used on a library that does not
|
||||
exist, exit with an error. (Fixes: :issue:`1298`)
|
||||
|
||||
|
||||
v1.1.1 (2015-09-14)
|
||||
===================
|
||||
|
||||
@ -21,8 +21,8 @@ def _get_library(args, config):
|
||||
library_name = config['local']['library']
|
||||
|
||||
if library_name not in libraries:
|
||||
logger.warning('Local library %s not found', library_name)
|
||||
return 1
|
||||
logger.error('Local library %s not found', library_name)
|
||||
return None
|
||||
|
||||
logger.debug('Using %s as the local library', library_name)
|
||||
return libraries[library_name](config)
|
||||
@ -41,6 +41,9 @@ class ClearCommand(commands.Command):
|
||||
|
||||
def run(self, args, config):
|
||||
library = _get_library(args, config)
|
||||
if library is None:
|
||||
return 1
|
||||
|
||||
prompt = '\nAre you sure you want to clear the library? [y/N] '
|
||||
|
||||
if compat.input(prompt).lower() != 'y':
|
||||
@ -76,6 +79,8 @@ class ScanCommand(commands.Command):
|
||||
bytes(file_ext.lower()) for file_ext in excluded_file_extensions)
|
||||
|
||||
library = _get_library(args, config)
|
||||
if library is None:
|
||||
return 1
|
||||
|
||||
file_mtimes, file_errors = path.find_mtimes(
|
||||
media_dir, follow=config['local']['scan_follow_symlinks'])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user