← Back to team overview

openlp-core team mailing list archive

Re: [Merge] lp:~tomasgroth/openlp/presentation-load-speedup into lp:openlp

 

Review: Needs Information

Just a question about os.path vs Path

Diff comments:

> 
> === modified file 'openlp/core/lib/serviceitem.py'
> --- openlp/core/lib/serviceitem.py	2019-05-24 22:11:11 +0000
> +++ openlp/core/lib/serviceitem.py	2019-06-20 20:25:58 +0000
> @@ -254,18 +259,22 @@
>          :param image: The command of/for the slide.
>          :param display_title: Title to show in gui/webinterface, optional.
>          :param notes: Notes to show in the webinteface, optional.
> +        :param file_hash: Sha256 hash checksum of the file.
>          """
>          self.service_item_type = ServiceItemType.Command
>          # If the item should have a display title but this frame doesn't have one, we make one up
>          if self.is_capable(ItemCapabilities.HasDisplayTitle) and not display_title:
>              display_title = translate('OpenLP.ServiceItem',
>                                        '[slide {frame:d}]').format(frame=len(self.slides) + 1)
> +        if file_hash:
> +            self.sha256_file_hash = file_hash
> +        else:
> +            file_location = os.path.join(path, file_name)

Shouldn't we be using Path objects?

> +            self.sha256_file_hash = sha256_file_hash(file_location)
>          # Update image path to match servicemanager location if file was loaded from service
>          if image and not self.has_original_files and self.name == 'presentations':
> -            file_location = os.path.join(path, file_name)
> -            file_location_hash = md5_hash(file_location.encode('utf-8'))
> -            image = os.path.join(AppLocation.get_section_data_path(self.name), 'thumbnails', file_location_hash,
> -                                 ntpath.basename(image))  # TODO: Pathlib
> +            image = os.path.join(str(AppLocation.get_section_data_path(self.name)), 'thumbnails',
> +                                 self.sha256_file_hash, ntpath.basename(image))
>          self.slides.append({'title': file_name, 'image': image, 'path': path, 'display_title': display_title,
>                              'notes': notes, 'thumbnail': image})
>          # if self.is_capable(ItemCapabilities.HasThumbnails):


-- 
https://code.launchpad.net/~tomasgroth/openlp/presentation-load-speedup/+merge/367933
Your team OpenLP Core is subscribed to branch lp:openlp.


References