diff --git a/app/services/projects/update_pages_configuration_service.rb b/app/services/projects/update_pages_configuration_service.rb index b5324587d0eb18939017489b5c6654be4f6ce0e4..188847b5ad663bd3d9147a167ba498527b991fa6 100644 --- a/app/services/projects/update_pages_configuration_service.rb +++ b/app/services/projects/update_pages_configuration_service.rb @@ -7,7 +7,7 @@ module Projects end def execute - update_file(pages_config_file, pages_config) + update_file(pages_config_file, pages_config.to_json) reload_daemon success rescue => e @@ -52,18 +52,18 @@ module Projects def update_file(file, data) unless data - File.rm(file, force: true) + FileUtils.remove(file, force: true) return end temp_file = "#{file}.#{SecureRandom.hex(16)}" - File.open(temp_file, 'w') do |file| - file.write(data) + File.open(temp_file, 'w') do |f| + f.write(data) end - File.mv(temp_file, file, force: true) + FileUtils.move(temp_file, file, force: true) ensure # In case if the updating fails - File.rm(temp_file, force: true) + FileUtils.remove(temp_file, force: true) end end end