diff --git a/.gitignore b/.gitignore index 3cfaabda4..243dc338d 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ tests/visual_test/img/ *.swn tests/visual_test/build build -*.so \ No newline at end of file +*.so +nohup.out diff --git a/thumbor/handlers/upload.py b/thumbor/handlers/upload.py index fc062da93..bc7f0b764 100644 --- a/thumbor/handlers/upload.py +++ b/thumbor/handlers/upload.py @@ -18,14 +18,13 @@ class UploadHandler(ContextHandler): def write_file(self, filename, body, overwrite): storage = self.context.modules.original_photo_storage path = storage.resolve_original_photo_path(filename) - normalized_path = storage.normalize_path(path) - if not overwrite and exists(normalized_path): + if not overwrite and storage.exists(path): raise RuntimeError('File already exists.') - storage.put(path, body) + stored_path = storage.put(path, body) - return path + return stored_path def extract_file_data(self): if not 'media' in self.request.files: raise RuntimeError("File was not uploaded properly.") diff --git a/thumbor/storages/file_storage.py b/thumbor/storages/file_storage.py index ac471850d..f7e601a40 100644 --- a/thumbor/storages/file_storage.py +++ b/thumbor/storages/file_storage.py @@ -32,7 +32,7 @@ def put(self, path, bytes): with open(file_abspath, 'w') as _file: _file.write(bytes) - return file_abspath + return path def put_crypto(self, path): if not self.context.config.STORES_CRYPTO_KEY_FOR_EACH_IMAGE: diff --git a/vows/upload_vows.py b/vows/upload_vows.py index f4a6653be..e1babfc1f 100644 --- a/vows/upload_vows.py +++ b/vows/upload_vows.py @@ -25,7 +25,8 @@ storage_path = '/tmp/thumbor-vows/storage' crocodile_file_path = abspath(join(dirname(__file__), 'crocodile.jpg')) -rmtree(storage_path) +if exists(storage_path): + rmtree(storage_path) def get_content_type(filename): return mimetypes.guess_type(filename)[0] or 'application/octet-stream' @@ -90,6 +91,7 @@ def get_app(self): cfg.ORIGINAL_PHOTO_STORAGE = 'thumbor.storages.file_storage' cfg.FILE_STORAGE_ROOT_PATH = storage_path cfg.ALLOW_ORIGINAL_PHOTO_DELETION = True + cfg.ALLOW_ORIGINAL_PHOTO_PUTTING = True importer = Importer(cfg) importer.import_modules()