From b149a5b3ed45e340431e6dc407388366a73a82c1 Mon Sep 17 00:00:00 2001 From: Francesco Siddi Date: Fri, 26 Feb 2016 16:59:58 +0100 Subject: [PATCH] Hack to make thumbnails of size t public This should be fixed as soon as possible, by making the push_to_storage function data-aware. --- pillar/application/modules/file_storage.py | 6 ++++++ pillar/application/utils/storage.py | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pillar/application/modules/file_storage.py b/pillar/application/modules/file_storage.py index 87da5626..3c3610b4 100644 --- a/pillar/application/modules/file_storage.py +++ b/pillar/application/modules/file_storage.py @@ -91,6 +91,12 @@ def build_thumbnails(file_path=None, file_id=None): md5=thumbnail['md5'], file_path=basename, ) + # XXX Inject is_public for size 't' (should be part of the upload), + # and currently we set it here and then on the fly during blob + # creation by simply parsing the extension of the filename. This is + # bad. + if size == 't': + file_variation['is_public'] = True file_variations.append(file_variation) diff --git a/pillar/application/utils/storage.py b/pillar/application/utils/storage.py index 73621861..8ba97785 100644 --- a/pillar/application/utils/storage.py +++ b/pillar/application/utils/storage.py @@ -65,7 +65,12 @@ def push_to_storage(project_id, full_path, backend='cgs'): def push_single_file(project_id, full_path, backend): if backend == 'cgs': storage = GoogleCloudStorageBucket(project_id, subdir='_') - storage.Post(full_path) + blob = storage.Post(full_path) + # XXX Make public on the fly if it's an image and small preview. + # This should happen by reading the database (push to storage + # should change to accomodate it). + if full_path.endswith('-t.jpg'): + blob.make_public() os.remove(full_path) if os.path.isfile(full_path):