From cef1563b4b7e517555d5f3cc9aa0a1f3c74f8cd7 Mon Sep 17 00:00:00 2001 From: Ade Date: Tue, 25 Apr 2017 17:03:59 +1200 Subject: [PATCH] Trap errors for Scan --- headphones/webserve.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/headphones/webserve.py b/headphones/webserve.py index 855fed24..f46b5254 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -871,11 +871,19 @@ class WebInterface(object): def musicScan(self, path, scan=0, redirect=None, autoadd=0, libraryscan=0): headphones.CONFIG.LIBRARYSCAN = libraryscan headphones.CONFIG.AUTO_ADD_ARTISTS = autoadd - headphones.CONFIG.MUSIC_DIR = path - headphones.CONFIG.write() + + try: + params = {} + headphones.CONFIG.MUSIC_DIR = path + headphones.CONFIG.write() + except Exception as e: + logger.warn("Cannot save scan directory to config: %s", e) + if scan: + params = {"dir": path} + if scan: try: - threading.Thread(target=librarysync.libraryScan).start() + threading.Thread(target=librarysync.libraryScan, kwargs=params).start() except Exception as e: logger.error('Unable to complete the scan: %s' % e) if redirect: