mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Style
This commit is contained in:
parent
97b2978d70
commit
fcdbaf7e61
1 changed files with 10 additions and 6 deletions
|
@ -20,22 +20,26 @@ class ActiveFile::Sites::DiskSite < ActiveFile::Site
|
|||
|
||||
def download(key)
|
||||
if block_given?
|
||||
open(path_for(key)) do |file|
|
||||
File.open(path_for(key)) do |file|
|
||||
while data = file.read(65536)
|
||||
yield data
|
||||
end
|
||||
end
|
||||
else
|
||||
open(path_for(key), &:read)
|
||||
File.open path_for(key), &:read
|
||||
end
|
||||
end
|
||||
|
||||
def delete(key)
|
||||
File.delete(path_for(key))
|
||||
File.delete path_for(key)
|
||||
end
|
||||
|
||||
def exists?(key)
|
||||
File.exist? path_for(key)
|
||||
end
|
||||
|
||||
def size(key)
|
||||
File.size(path_for(key))
|
||||
File.size path_for(key)
|
||||
end
|
||||
|
||||
def checksum(key)
|
||||
|
@ -44,11 +48,11 @@ class ActiveFile::Sites::DiskSite < ActiveFile::Site
|
|||
|
||||
private
|
||||
def path_for(key)
|
||||
File.join(root, folder_for(key), key)
|
||||
File.join root, folder_for(key), key
|
||||
end
|
||||
|
||||
def folder_for(key)
|
||||
[key[0..1], key[2..3]].join("/")
|
||||
[ key[0..1], key[2..3] ].join("/")
|
||||
end
|
||||
|
||||
def make_path_for(key)
|
||||
|
|
Loading…
Reference in a new issue