lib/s3repo/cache.rb in s3repo-0.3.4 vs lib/s3repo/cache.rb in s3repo-1.0.0

- old
+ new

@@ -4,18 +4,23 @@ module S3Repo ## # Cache object, stores S3 objects on disk class Cache < Base - TMPDIRS = [ENV['S3REPO_TMPDIR'], ENV['TMPDIR'], Dir.tmpdir, '/tmp/s3repo'] + TMPDIRS = [ + ENV['S3REPO_TMPDIR'], + ENV['TMPDIR'], + Dir.tmpdir, + '/tmp/s3repo' + ].freeze def initialize(params = {}) super [partialdir, cachedir].each { |x| FileUtils.mkdir_p x } end def serve(key, refresh = true) - File.open(download(key, refresh)) { |fh| fh.read } + File.open(download(key, refresh), &:read) rescue Aws::S3::Errors::NoSuchKey nil end private