1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
This commit is contained in:
David Heinemeier Hansson 2017-07-01 12:05:58 +02:00
parent 97b2978d70
commit fcdbaf7e61

View file

@ -20,22 +20,26 @@ class ActiveFile::Sites::DiskSite < ActiveFile::Site
def download(key) def download(key)
if block_given? if block_given?
open(path_for(key)) do |file| File.open(path_for(key)) do |file|
while data = file.read(65536) while data = file.read(65536)
yield data yield data
end end
end end
else else
open(path_for(key), &:read) File.open path_for(key), &:read
end end
end end
def delete(key) def delete(key)
File.delete(path_for(key)) File.delete path_for(key)
end
def exists?(key)
File.exist? path_for(key)
end end
def size(key) def size(key)
File.size(path_for(key)) File.size path_for(key)
end end
def checksum(key) def checksum(key)
@ -44,7 +48,7 @@ class ActiveFile::Sites::DiskSite < ActiveFile::Site
private private
def path_for(key) def path_for(key)
File.join(root, folder_for(key), key) File.join root, folder_for(key), key
end end
def folder_for(key) def folder_for(key)