From 79c1335d4169f9c6620d3c244ea3792e84f79902 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Tue, 10 Mar 2015 22:00:32 +0000 Subject: [PATCH] Only update presentation thumbnails if needed. Fixes bug 1424330. Fixes: https://launchpad.net/bugs/1424330 --- openlp/plugins/presentations/lib/mediaitem.py | 17 +++++++++++++---- .../plugins/presentations/presentationplugin.py | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 10b295235..00a529b63 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -230,17 +230,26 @@ class PresentationMediaItem(MediaManagerItem): Settings().setValue(self.settings_section + '/presentations files', self.get_file_list()) self.application.set_normal_cursor() - def clean_up_thumbnails(self, filepath): + def clean_up_thumbnails(self, filepath, clean_for_update=False): """ Clean up the files created such as thumbnails :param filepath: File path of the presention to clean up after + :param clean_for_update: Only clean thumbnails if update is needed :return: None """ for cidx in self.controllers: - doc = self.controllers[cidx].add_document(filepath) - doc.presentation_deleted() - doc.close_presentation() + root, file_ext = os.path.splitext(filepath) + file_ext = file_ext[1:] + if file_ext in self.controllers[cidx].supports or file_ext in self.controllers[cidx].also_supports: + doc = self.controllers[cidx].add_document(filepath) + if clean_for_update: + thumb_path = doc.get_thumbnail_path(1, True) + if not thumb_path or os.path.getmtime(thumb_path) < os.path.getmtime(filepath): + doc.presentation_deleted() + else: + doc.presentation_deleted() + doc.close_presentation() def generate_slide_data(self, service_item, item=None, xml_version=False, remote=False, context=ServiceItemContext.Service, presentation_file=None): diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 44470b578..aaa190c73 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -144,7 +144,7 @@ class PresentationPlugin(Plugin): files_from_config = Settings().value('presentations/presentations files') for file in files_from_config: try: - self.media_item.clean_up_thumbnails(file) + self.media_item.clean_up_thumbnails(file, True) except AttributeError: pass self.media_item.list_view.clear()