Only update presentation thumbnails if needed. Fixes bug 1424330.

Fixes: https://launchpad.net/bugs/1424330
This commit is contained in:
Tomas Groth 2015-03-10 22:00:32 +00:00
parent 976408fe8e
commit 79c1335d41
2 changed files with 14 additions and 5 deletions

View File

@ -230,17 +230,26 @@ class PresentationMediaItem(MediaManagerItem):
Settings().setValue(self.settings_section + '/presentations files', self.get_file_list()) Settings().setValue(self.settings_section + '/presentations files', self.get_file_list())
self.application.set_normal_cursor() 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 Clean up the files created such as thumbnails
:param filepath: File path of the presention to clean up after :param filepath: File path of the presention to clean up after
:param clean_for_update: Only clean thumbnails if update is needed
:return: None :return: None
""" """
for cidx in self.controllers: for cidx in self.controllers:
doc = self.controllers[cidx].add_document(filepath) root, file_ext = os.path.splitext(filepath)
doc.presentation_deleted() file_ext = file_ext[1:]
doc.close_presentation() 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, def generate_slide_data(self, service_item, item=None, xml_version=False, remote=False,
context=ServiceItemContext.Service, presentation_file=None): context=ServiceItemContext.Service, presentation_file=None):

View File

@ -144,7 +144,7 @@ class PresentationPlugin(Plugin):
files_from_config = Settings().value('presentations/presentations files') files_from_config = Settings().value('presentations/presentations files')
for file in files_from_config: for file in files_from_config:
try: try:
self.media_item.clean_up_thumbnails(file) self.media_item.clean_up_thumbnails(file, True)
except AttributeError: except AttributeError:
pass pass
self.media_item.list_view.clear() self.media_item.list_view.clear()