mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-19 21:57:54 +00:00
Merge pull request #70 from resin-io/revert-64-63-write-configjson-atomically
Revert "Make config.json writes atomic"
This commit is contained in:
commit
2ae6a44a12
@ -1,5 +1,3 @@
|
||||
* Make config.json writes atomic [Pablo]
|
||||
|
||||
# v1.3.2
|
||||
|
||||
* Do not report the tun addresses to API [Praneeth]
|
||||
|
@ -6,7 +6,6 @@ deviceRegister = require 'resin-register-device'
|
||||
{ resinApi } = require './request'
|
||||
fs = Promise.promisifyAll(require('fs'))
|
||||
EventEmitter = require('events').EventEmitter
|
||||
execAsync = Promise.promisify(require('child_process').exec)
|
||||
config = require './config'
|
||||
configPath = '/boot/config.json'
|
||||
appsPath = '/boot/apps.json'
|
||||
@ -49,7 +48,7 @@ bootstrap = ->
|
||||
.then (device) ->
|
||||
userConfig.registered_at = Date.now()
|
||||
userConfig.deviceId = device.id
|
||||
writeConfigFile(userConfig)
|
||||
fs.writeFileAsync(configPath, JSON.stringify(userConfig))
|
||||
.return(userConfig)
|
||||
.then (userConfig) ->
|
||||
console.log('Finishing bootstrapping')
|
||||
@ -67,14 +66,6 @@ bootstrap = ->
|
||||
.tap ->
|
||||
bootstrapper.doneBootstrapping()
|
||||
|
||||
|
||||
writeConfigFile = (config) ->
|
||||
fs.writeFileAsync(configPath + '.new', JSON.stringify(config))
|
||||
.then ->
|
||||
fs.renameAsync(configPath + '.new', configPath)
|
||||
.then ->
|
||||
execAsync('sync')
|
||||
|
||||
readConfigAndEnsureUUID = ->
|
||||
# Load config file
|
||||
fs.readFileAsync(configPath, 'utf8')
|
||||
@ -85,7 +76,7 @@ readConfigAndEnsureUUID = ->
|
||||
deviceRegister.generateUUID()
|
||||
.then (uuid) ->
|
||||
userConfig.uuid = uuid
|
||||
writeConfigFile(userConfig)
|
||||
fs.writeFileAsync(configPath, JSON.stringify(userConfig))
|
||||
.return(uuid)
|
||||
.catch (err) ->
|
||||
console.log('Error generating and saving UUID: ', err)
|
||||
|
Loading…
Reference in New Issue
Block a user