Use synchronize_session=fetch when synchronizing records on deletion

This commit is contained in:
Fabio Manganiello 2019-02-19 00:32:54 +01:00
parent 11af83f88f
commit 8a6be8b540

View file

@ -129,7 +129,8 @@ class LocalMediaSearcher(MediaSearcher):
self.logger.info('Directory {} is no longer accessible, removing it'.
format(media_dir))
session.query(MediaDirectory) \
.filter(MediaDirectory.path==media_dir).delete()
.filter(MediaDirectory.path==media_dir) \
.delete(synchronize_session='fetch')
return
stored_file_records = {
@ -177,7 +178,7 @@ class LocalMediaSearcher(MediaSearcher):
session.query(MediaFile).filter(MediaFile.id.in_(
[ record.id for record in stored_file_records.values() ]
)).delete()
)).delete(synchronize_session='fetch')
dir_record.last_indexed_at = datetime.datetime.now()
self.logger.info('Scanned {} in {} seconds'.format(