use one variable to track app shutdown state
This commit is contained in:
parent
0cc3a4523e
commit
567952d91d
7 changed files with 35 additions and 44 deletions
|
|
@ -31,7 +31,7 @@ def remove_missing():
|
|||
prefix = os.path.join(os.path.expanduser(prefs['libraryPath']), 'Books' + os.sep)
|
||||
if os.path.exists(prefix):
|
||||
for f in File.query:
|
||||
if not state.tasks.connected:
|
||||
if state.shutdown:
|
||||
return
|
||||
if f.item:
|
||||
path = f.item.get_path()
|
||||
|
|
@ -45,7 +45,7 @@ def remove_missing():
|
|||
state.db.session.commit()
|
||||
state.cache.clear('group:')
|
||||
for f in File.query:
|
||||
if not state.tasks.connected:
|
||||
if state.shutdown:
|
||||
return
|
||||
f.move()
|
||||
remove_empty_folders(prefix, True)
|
||||
|
|
@ -82,7 +82,7 @@ def run_scan():
|
|||
books = []
|
||||
for root, folders, files in os.walk(prefix):
|
||||
for f in files:
|
||||
if not state.tasks.connected:
|
||||
if state.shutdown:
|
||||
return
|
||||
#if f.startswith('._') or f == '.DS_Store':
|
||||
if f.startswith('.'):
|
||||
|
|
@ -97,7 +97,7 @@ def run_scan():
|
|||
position = 0
|
||||
added = 0
|
||||
for f in ox.sorted_strings(books):
|
||||
if not state.tasks.connected:
|
||||
if state.shutdown:
|
||||
return
|
||||
position += 1
|
||||
with db.session():
|
||||
|
|
@ -159,7 +159,7 @@ def run_import(options=None):
|
|||
count = 0
|
||||
for root, folders, files in os.walk(prefix):
|
||||
for f in files:
|
||||
if not state.tasks.connected:
|
||||
if state.shutdown:
|
||||
return
|
||||
#if f.startswith('._') or f == '.DS_Store':
|
||||
if f.startswith('.'):
|
||||
|
|
@ -217,7 +217,7 @@ def run_import(options=None):
|
|||
if state.activity.get('cancel'):
|
||||
state.activity = {}
|
||||
return
|
||||
if not state.tasks.connected:
|
||||
if state.shutdown:
|
||||
return
|
||||
if time.time() - last > 5:
|
||||
last = time.time()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue