Orphan finder: when iterating all projects, gracefully stop at CTRL+C
This commit is contained in:
parent
5ce02bbbfe
commit
4be05c8b57
@ -605,9 +605,13 @@ def find_orphan_files(proj_url):
|
|||||||
if proj_url == 'all':
|
if proj_url == 'all':
|
||||||
log.warning('Iterating over ALL projects, may take a while')
|
log.warning('Iterating over ALL projects, may take a while')
|
||||||
orphans = set()
|
orphans = set()
|
||||||
|
try:
|
||||||
for project in projects_coll.find({'_deleted': {'$ne': True}}, projection={'_id': 1}):
|
for project in projects_coll.find({'_deleted': {'$ne': True}}, projection={'_id': 1}):
|
||||||
proj_orphans = _find_orphan_files(project['_id'])
|
proj_orphans = _find_orphan_files(project['_id'])
|
||||||
orphans.update(proj_orphans)
|
orphans.update(proj_orphans)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
log.warning('Keyboard interrupt received, stopping now '
|
||||||
|
'and showing intermediary results.')
|
||||||
else:
|
else:
|
||||||
project = projects_coll.find_one({'url': proj_url}, projection={'_id': 1})
|
project = projects_coll.find_one({'url': proj_url}, projection={'_id': 1})
|
||||||
if not project:
|
if not project:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user