Beispiel #1
0
def thumbnail_exists(self, thumbnail_name):
    if self.remote_source:
        return False

    if utils.is_storage_local(self.source_storage):
        source_modtime = utils.get_modified_time(self.source_storage,
                                                 self.name)
    else:
        source = self.get_source_cache()
        if not source:
            return False
        source_modtime = source.modified

    if not source_modtime:
        return False

    local_thumbnails = utils.is_storage_local(self.thumbnail_storage)
    if local_thumbnails:
        thumbnail_modtime = utils.get_modified_time(self.thumbnail_storage,
                                                    thumbnail_name)
        if not thumbnail_modtime:
            return False
        return source_modtime <= thumbnail_modtime

    thumbnail = self.get_thumbnail_cache(thumbnail_name)
    if not thumbnail:
        return False
    thumbnail_modtime = thumbnail.modified

    return thumbnail
Beispiel #2
0
    def thumbnail_exists(self, thumbnail_name):
        """
        Calculate whether the thumbnail already exists and that the source is
        not newer than the thumbnail.

        If the source and thumbnail file storages are local, their file
        modification times are used. Otherwise the database cached modification
        times are used.
        """
        if self.remote_source:
            return False

        if utils.is_storage_local(self.source_storage):
            source_modtime = utils.get_modified_time(self.source_storage,
                                                     self.name)
        else:
            source = self.get_source_cache()
            if not source:
                return False
            source_modtime = source.modified

        if not source_modtime:
            return False

        local_thumbnails = utils.is_storage_local(self.thumbnail_storage)
        if local_thumbnails:
            thumbnail_modtime = utils.get_modified_time(
                self.thumbnail_storage, thumbnail_name)
            if not thumbnail_modtime:
                return False
            return source_modtime <= thumbnail_modtime

        thumbnail = self.get_thumbnail_cache(thumbnail_name)
        if not thumbnail:
            return False
        thumbnail_modtime = thumbnail.modified

        if thumbnail.modified and source_modtime <= thumbnail.modified:
            return thumbnail
        return False
Beispiel #3
0
    def thumbnail_exists(self, thumbnail_name):
        """
        Calculate whether the thumbnail already exists and that the source is
        not newer than the thumbnail.

        If the source and thumbnail file storages are local, their file
        modification times are used. Otherwise the database cached modification
        times are used.
        """
        if self.remote_source:
            return False

        if utils.is_storage_local(self.source_storage):
            source_modtime = utils.get_modified_time(
                self.source_storage, self.name)
        else:
            source = self.get_source_cache()
            if not source:
                return False
            source_modtime = source.modified

        if not source_modtime:
            return False

        local_thumbnails = utils.is_storage_local(self.thumbnail_storage)
        if local_thumbnails:
            thumbnail_modtime = utils.get_modified_time(
                self.thumbnail_storage, thumbnail_name)
            if not thumbnail_modtime:
                return False
            return source_modtime <= thumbnail_modtime

        thumbnail = self.get_thumbnail_cache(thumbnail_name)
        if not thumbnail:
            return False
        thumbnail_modtime = thumbnail.modified

        if thumbnail.modified and source_modtime <= thumbnail.modified:
            return thumbnail
        return False
Beispiel #4
0
 def get_thumbnail_modtime(self, thumbnail_name):
     return utils.get_modified_time(self.thumbnail_storage, thumbnail_name)
Beispiel #5
0
 def get_source_modtime(self):
     return utils.get_modified_time(self.source_storage, self.name)
Beispiel #6
0
 def get_thumbnail_modtime(self, thumbnail_name):
     return utils.get_modified_time(self.thumbnail_storage, thumbnail_name)
Beispiel #7
0
 def get_source_modtime(self):
     return utils.get_modified_time(self.source_storage, self.name)