##
# replace characters which cannot be represented in XML 1.0.
def xml_sanitize(str)
- str.gsub(/[\x00-\x08\x0b\x0c\x0e-\x20]/,'?')
+ str.gsub(/[\x00-\x08\x0b\x0c\x0e-\x1f]/, "?")
end
##
FileUtils.mkdir_p(File.dirname(data_file))
Zlib::GzipWriter.open(tmp_data) do |fh|
fh.write(changeset_dump(open_changesets))
+ fh.fdatasync
end
@state["sequence"] = sequence
File.open(tmp_state, "w") do |fh|
fh.write(YAML.dump(@state))
+ fh.fdatasync
end
# sanity check: the files we're moving into place
# should be non-empty.
- fail "Temporary gzip file should exist, but doesn't." unless File.exist?(tmp_data)
- fail "Temporary state file should exist, but doesn't." unless File.exist?(tmp_state)
- fail "Temporary gzip file should be non-empty, but isn't." if File.zero?(tmp_data)
- fail "Temporary state file should be non-empty, but isn't." if File.zero?(tmp_state)
+ raise "Temporary gzip file should exist, but doesn't." unless File.exist?(tmp_data)
+ raise "Temporary state file should exist, but doesn't." unless File.exist?(tmp_state)
+ raise "Temporary gzip file should be non-empty, but isn't." if File.zero?(tmp_data)
+ raise "Temporary state file should be non-empty, but isn't." if File.zero?(tmp_state)
FileUtils.mv(tmp_data, data_file)
FileUtils.mv(tmp_state, @config["state_file"])