more logging, reset cancel imort
This commit is contained in:
parent
216fd0c232
commit
cded8b586a
4 changed files with 25 additions and 2 deletions
|
|
@ -52,17 +52,23 @@ def remove_missing():
|
|||
def add_file(id, f, prefix, from_=None):
|
||||
user = state.user()
|
||||
path = f[len(prefix):]
|
||||
logger.debug('extract metadata %s %s', id, path)
|
||||
data = media.metadata(f, from_)
|
||||
logger.debug('create file %s %s', id, path)
|
||||
file = File.get_or_create(id, data, path)
|
||||
item = file.item
|
||||
item.add_user(user)
|
||||
item.added = datetime.utcnow()
|
||||
logger.debug('load metadata %s %s', id, path)
|
||||
item.load_metadata()
|
||||
Changelog.record(user, 'additem', item.id, file.info)
|
||||
Changelog.record(user, 'edititem', item.id, item.meta)
|
||||
logger.debug('extract icons %s %s', id, path)
|
||||
item.update_icons()
|
||||
item.modified = datetime.utcnow()
|
||||
logger.debug('save item %s', id)
|
||||
item.update()
|
||||
logger.debug('added file %s', id)
|
||||
return file
|
||||
|
||||
def run_scan():
|
||||
|
|
@ -103,8 +109,12 @@ def run_scan():
|
|||
|
||||
def run_import(options=None):
|
||||
options = options or {}
|
||||
|
||||
logger.debug('run_import')
|
||||
if state.activity.get('cancel'):
|
||||
logger.debug('import canceled')
|
||||
state.activity = {}
|
||||
return
|
||||
state.activity = {}
|
||||
prefs = settings.preferences
|
||||
prefix = os.path.expanduser(options.get('path', prefs['importPath']))
|
||||
if os.path.islink(prefix):
|
||||
|
|
@ -148,6 +158,7 @@ def run_import(options=None):
|
|||
books.append(f)
|
||||
count += 1
|
||||
if state.activity.get('cancel'):
|
||||
logger.debug('active import canceled')
|
||||
state.activity = {}
|
||||
return
|
||||
if count % 1000 == 0:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue