Fix typos

This commit is contained in:
Erik Johnston 2017-10-12 15:28:24 +01:00
parent 67cb89fbdf
commit c8eeef6947

View File

@ -65,6 +65,8 @@ class MediaRepository(object):
if hs.config.backup_media_store_path: if hs.config.backup_media_store_path:
self.backup_filepaths = MediaFilePaths(hs.config.backup_media_store_path) self.backup_filepaths = MediaFilePaths(hs.config.backup_media_store_path)
self.synchronous_backup_media_store = hs.config.synchronous_backup_media_store
self.dynamic_thumbnails = hs.config.dynamic_thumbnails self.dynamic_thumbnails = hs.config.dynamic_thumbnails
self.thumbnail_requirements = hs.config.thumbnail_requirements self.thumbnail_requirements = hs.config.thumbnail_requirements
@ -112,12 +114,12 @@ class MediaRepository(object):
# We can either wait for successful writing to the backup repository # We can either wait for successful writing to the backup repository
# or write in the background and immediately return # or write in the background and immediately return
if hs.config.synchronous_backup_media_store: if self.synchronous_backup_media_store:
yield preserve_context_over_fn( yield preserve_context_over_fn(
threads.deferToThread, write_file_thread, backup_fname, threads.deferToThread, write_file_thread, backup_fname,
) )
else: else:
preserve_fn(threads.deferToThread)(write_file, backup_fname) preserve_fn(threads.deferToThread)(write_file_thread, backup_fname)
defer.returnValue(fname) defer.returnValue(fname)
@ -321,7 +323,7 @@ class MediaRepository(object):
if t_byte_source: if t_byte_source:
output_path = yield self._write_to_file( output_path = yield self._write_to_file(
content, t_byte_source,
lambda f: f.local_media_thumbnail( lambda f: f.local_media_thumbnail(
media_id, t_width, t_height, t_type, t_method media_id, t_width, t_height, t_type, t_method
) )
@ -329,10 +331,11 @@ class MediaRepository(object):
logger.info("Stored thumbnail in file %r", output_path) logger.info("Stored thumbnail in file %r", output_path)
yield self.store.store_local_thumbnail( yield self.store.store_local_thumbnail(
media_id, t_width, t_height, t_type, t_method, len(t_byte_source.getvalue()) media_id, t_width, t_height, t_type, t_method,
len(t_byte_source.getvalue())
) )
defer.returnValue(t_path) defer.returnValue(output_path)
@defer.inlineCallbacks @defer.inlineCallbacks
def generate_remote_exact_thumbnail(self, server_name, file_id, media_id, def generate_remote_exact_thumbnail(self, server_name, file_id, media_id,
@ -348,7 +351,7 @@ class MediaRepository(object):
if t_byte_source: if t_byte_source:
output_path = yield self._write_to_file( output_path = yield self._write_to_file(
content, t_byte_source,
lambda f: f.remote_media_thumbnail( lambda f: f.remote_media_thumbnail(
server_name, file_id, t_width, t_height, t_type, t_method server_name, file_id, t_width, t_height, t_type, t_method
) )
@ -360,7 +363,7 @@ class MediaRepository(object):
t_width, t_height, t_type, t_method, len(t_byte_source.getvalue()) t_width, t_height, t_type, t_method, len(t_byte_source.getvalue())
) )
defer.returnValue(t_path) defer.returnValue(output_path)
@defer.inlineCallbacks @defer.inlineCallbacks
def _generate_local_thumbnails(self, media_id, media_info, url_cache=False): def _generate_local_thumbnails(self, media_id, media_info, url_cache=False):
@ -400,19 +403,21 @@ class MediaRepository(object):
yield preserve_context_over_fn(threads.deferToThread, generate_thumbnails) yield preserve_context_over_fn(threads.deferToThread, generate_thumbnails)
for t_width, t_height, t_method, t_type, t_byte_source in local_thumbnails: for t_width, t_height, t_method, t_type, t_byte_source in local_thumbnails:
if url_cache: def path_name_func(f):
path_name_func = lambda f: f.url_cache_thumbnail( if url_cache:
media_id, t_width, t_height, t_type, t_method return f.url_cache_thumbnail(
) media_id, t_width, t_height, t_type, t_method
else: )
path_name_func = lambda f: f.local_media_thumbnail( else:
media_id, t_width, t_height, t_type, t_method return f.local_media_thumbnail(
) media_id, t_width, t_height, t_type, t_method
)
yield self._write_to_file(t_byte_source, path_name_func) yield self._write_to_file(t_byte_source, path_name_func)
yield self.store.store_local_thumbnail( yield self.store.store_local_thumbnail(
media_id, t_width, t_height, t_type, t_method, len(t_byte_source.getvalue()) media_id, t_width, t_height, t_type, t_method,
len(t_byte_source.getvalue())
) )
defer.returnValue({ defer.returnValue({
@ -457,10 +462,11 @@ class MediaRepository(object):
for r in remote_thumbnails: for r in remote_thumbnails:
yield self.store.store_remote_media_thumbnail(*r) yield self.store.store_remote_media_thumbnail(*r)
for t_width, t_height, t_method, t_type, t_byte_source in local_thumbnails: for t_width, t_height, t_method, t_type, t_byte_source in remote_thumbnails:
path_name_func = lambda f: f.remote_media_thumbnail( def path_name_func(f):
server_name, media_id, file_id, t_width, t_height, t_type, t_method return f.remote_media_thumbnail(
) server_name, media_id, file_id, t_width, t_height, t_type, t_method
)
yield self._write_to_file(t_byte_source, path_name_func) yield self._write_to_file(t_byte_source, path_name_func)