From 4076cd351851be38b61887262c9ca9b243dfdeb1 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 17 Feb 2019 16:04:46 +0100 Subject: [PATCH] Sync removed directories in the media index --- platypush/plugins/media/local.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/platypush/plugins/media/local.py b/platypush/plugins/media/local.py index ca857c8eea..7a38741cd3 100644 --- a/platypush/plugins/media/local.py +++ b/platypush/plugins/media/local.py @@ -125,6 +125,13 @@ class LocalMediaSearcher: if not dir_record: dir_record = self._get_or_create_dir_entry(session, media_dir) + if not os.path.isdir(media_dir): + self.logger.info('Directory {} is no longer accessible, removing it'. + format(media_dir)) + session.query(MediaDirectory). \ + filter(MediaDirectory.path=media_dir).delete() + return + stored_file_records = { f.path: f for f in self._get_file_records(dir_record, session) }