lib/geminabox/proxy/splicer.rb in geminabox-0.13.1 vs lib/geminabox/proxy/splicer.rb in geminabox-0.13.2

- old
+ new

@@ -1,17 +1,27 @@ +require 'tempfile' module Geminabox module Proxy class Splicer < FileHandler - + def self.make(file_name) splicer = new(file_name) splicer.create splicer end def create - File.open(splice_path, 'w'){|f| f.write(new_content)} + data = new_content + return nil if data.nil? + begin + tmp = Tempfile.new('geminabox') + File.open(tmp, 'w'){|f| f.write(data)} + rescue + return nil + end + + FileUtils.mv tmp, splice_path end def new_content if local_file_exists? merge_content