From 4150dbb60d7105128be00d1786661a82d4f2acc7 Mon Sep 17 00:00:00 2001 From: Ruud Date: Mon, 11 Jun 2012 21:13:06 +0200 Subject: [PATCH] Don't save empty filepath and log the error. fix #389 --- couchpotato/core/plugins/file/main.py | 2 ++ couchpotato/core/plugins/library/main.py | 15 ++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/couchpotato/core/plugins/file/main.py b/couchpotato/core/plugins/file/main.py index 125748fb..5f381198 100644 --- a/couchpotato/core/plugins/file/main.py +++ b/couchpotato/core/plugins/file/main.py @@ -8,6 +8,7 @@ from couchpotato.core.plugins.base import Plugin from couchpotato.core.settings.model import FileType, File from couchpotato.environment import Env import os.path +import traceback log = CPLog(__name__) @@ -46,6 +47,7 @@ class FileManager(Plugin): try: filedata = self.urlopen(url, **urlopen_kwargs) except: + log.error('Failed downloading file %s: %s', (url, traceback.format_exc())) return False self.createFile(dest, filedata, binary = True) diff --git a/couchpotato/core/plugins/library/main.py b/couchpotato/core/plugins/library/main.py index b8e3af4e..d24dfca6 100644 --- a/couchpotato/core/plugins/library/main.py +++ b/couchpotato/core/plugins/library/main.py @@ -117,13 +117,14 @@ class LibraryPlugin(Plugin): continue file_path = fireEvent('file.download', url = image, single = True) - file_obj = fireEvent('file.add', path = file_path, type_tuple = ('image', type), single = True) - try: - file_obj = db.query(File).filter_by(id = file_obj.get('id')).one() - library.files.append(file_obj) - db.commit() - except: - log.debug('Failed to attach to library: %s', traceback.format_exc()) + if file_path: + file_obj = fireEvent('file.add', path = file_path, type_tuple = ('image', type), single = True) + try: + file_obj = db.query(File).filter_by(id = file_obj.get('id')).one() + library.files.append(file_obj) + db.commit() + except: + log.debug('Failed to attach to library: %s', traceback.format_exc()) library_dict = library.to_dict(self.default_dict)