Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
heynemann committed Feb 21, 2012
1 parent af93e19 commit dbb1bf4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -12,4 +12,5 @@ tests/visual_test/img/
*.swn
tests/visual_test/build
build
*.so
*.so
nohup.out
7 changes: 3 additions & 4 deletions thumbor/handlers/upload.py
Expand Up @@ -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.")
Expand Down
2 changes: 1 addition & 1 deletion thumbor/storages/file_storage.py
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion vows/upload_vows.py
Expand Up @@ -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'
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit dbb1bf4

Please sign in to comment.