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