lib/tori/backend/filesystem.rb in tori-0.2.0 vs lib/tori/backend/filesystem.rb in tori-0.3.0
- old
+ new
@@ -8,21 +8,23 @@
end
def write(filename, resource, opts = nil)
case resource
when String
- ::File.open(path(filename), 'w'){ |f| f.write resource }
+ ::File.open(path(filename), 'wb'){ |f| f.write resource }
when Pathname
# see also https://bugs.ruby-lang.org/issues/11199
::File.open(resource) { |src|
FileUtils.mkdir_p path(filename).dirname
- ::File.open(path(filename), 'w'){ |dst|
+ ::File.open(path(filename), 'wb'){ |dst|
::IO.copy_stream src, dst
}
}
else
- ::IO.copy_stream resource, path(filename)
+ ::File.open(path(filename), 'wb') do |dst|
+ ::IO.copy_stream resource, dst
+ end
end
end
def delete(filename)
::File.unlink path(filename)
@@ -32,10 +34,10 @@
::File.exist? path(filename)
end
alias exists? exist?
def read(filename)
- ::File.read path(filename)
+ ::File.read(path(filename), mode: 'rb')
end
def path(filename)
@root.join filename.to_s
end