FIX: automatically growing uploads tree

This commit is contained in:
Régis Hanol
2015-05-28 01:03:24 +02:00
parent 1b96a3acc1
commit 8e7bfd0f29
8 changed files with 38 additions and 46 deletions

View File

@ -5,12 +5,12 @@ module FileStore
class LocalStore < BaseStore
def store_upload(file, upload, content_type = nil)
path = get_path_for_upload(file, upload)
path = get_path_for_upload(upload)
store_file(file, path)
end
def store_optimized_image(file, optimized_image)
path = get_path_for_optimized_image(file, optimized_image)
path = get_path_for_optimized_image(optimized_image)
store_file(file, path)
end
@ -57,17 +57,8 @@ module FileStore
private
def get_path_for_upload(file, upload)
get_path_for("original".freeze, upload.sha1, upload.extension)
end
def get_path_for_optimized_image(file, optimized_image)
extension = "_#{optimized_image.width}x#{optimized_image.height}#{optimized_image.extension}"
get_path_for("optimized".freeze, optimized_image.sha1, extension)
end
def get_path_for(type, sha, extension)
"#{relative_base_url}/#{type}/#{sha[0]}/#{sha[1]}/#{sha}#{extension}"
def get_path_for(type, upload_id, sha, extension)
"#{relative_base_url}/#{super(type, upload_id, sha, extension)}"
end
def store_file(file, path)