44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/synapse/config_generator/file_output.rb', line 44
def write_backends_to_file(service_name, new_backends)
data_path = File.join(opts['output_directory'], "#{service_name}.json")
begin
old_backends = JSON.load(File.read(data_path))
rescue Errno::ENOENT
old_backends = nil
end
if old_backends == new_backends
return false
else
temp_path = File.join(opts['output_directory'],
".#{service_name}.json.tmp")
File.open(temp_path, 'w', 0644) {|f| f.write(new_backends.to_json)}
FileUtils.mv(temp_path, data_path)
return true
end
end
|