Don't save empty filepath and log the error. fix #389
This commit is contained in:
@@ -8,6 +8,7 @@ from couchpotato.core.plugins.base import Plugin
|
|||||||
from couchpotato.core.settings.model import FileType, File
|
from couchpotato.core.settings.model import FileType, File
|
||||||
from couchpotato.environment import Env
|
from couchpotato.environment import Env
|
||||||
import os.path
|
import os.path
|
||||||
|
import traceback
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
@@ -46,6 +47,7 @@ class FileManager(Plugin):
|
|||||||
try:
|
try:
|
||||||
filedata = self.urlopen(url, **urlopen_kwargs)
|
filedata = self.urlopen(url, **urlopen_kwargs)
|
||||||
except:
|
except:
|
||||||
|
log.error('Failed downloading file %s: %s', (url, traceback.format_exc()))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.createFile(dest, filedata, binary = True)
|
self.createFile(dest, filedata, binary = True)
|
||||||
|
|||||||
@@ -117,13 +117,14 @@ class LibraryPlugin(Plugin):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
file_path = fireEvent('file.download', url = image, single = True)
|
file_path = fireEvent('file.download', url = image, single = True)
|
||||||
file_obj = fireEvent('file.add', path = file_path, type_tuple = ('image', type), single = True)
|
if file_path:
|
||||||
try:
|
file_obj = fireEvent('file.add', path = file_path, type_tuple = ('image', type), single = True)
|
||||||
file_obj = db.query(File).filter_by(id = file_obj.get('id')).one()
|
try:
|
||||||
library.files.append(file_obj)
|
file_obj = db.query(File).filter_by(id = file_obj.get('id')).one()
|
||||||
db.commit()
|
library.files.append(file_obj)
|
||||||
except:
|
db.commit()
|
||||||
log.debug('Failed to attach to library: %s', traceback.format_exc())
|
except:
|
||||||
|
log.debug('Failed to attach to library: %s', traceback.format_exc())
|
||||||
|
|
||||||
library_dict = library.to_dict(self.default_dict)
|
library_dict = library.to_dict(self.default_dict)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user