diff --git a/lib/active_file/sites/disk_site.rb b/lib/active_file/sites/disk_site.rb index 2466b665c4..9068e14866 100644 --- a/lib/active_file/sites/disk_site.rb +++ b/lib/active_file/sites/disk_site.rb @@ -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)