From 8a6be8b5403095197b92cfe41846096fce1d3a8d Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 19 Feb 2019 00:32:54 +0100 Subject: [PATCH] Use synchronize_session=fetch when synchronizing records on deletion --- platypush/plugins/media/search/local.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platypush/plugins/media/search/local.py b/platypush/plugins/media/search/local.py index 3691c39d01..f35baa2537 100644 --- a/platypush/plugins/media/search/local.py +++ b/platypush/plugins/media/search/local.py @@ -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(