mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Call fsync() before closing file
This commit is contained in:
parent
2b9aa94f3a
commit
da708adcbd
@ -137,7 +137,8 @@
|
||||
"empty": "Existing __type__ file is empty",
|
||||
"invalid": "Existing __type__ file is not valid json",
|
||||
"restore": "Restoring __type__ file backup : __path__",
|
||||
"restore-fail": "Restoring __type__ file backup failed : __message__"
|
||||
"restore-fail": "Restoring __type__ file backup failed : __message__",
|
||||
"fsync-fail": "Flushing file __path__ to disk failed : __message__"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -114,8 +114,13 @@ function writeFile(path,content) {
|
||||
return when.promise(function(resolve,reject) {
|
||||
var stream = fs.createWriteStream(path);
|
||||
stream.on('open',function(fd) {
|
||||
stream.end(content,'utf8',function() {
|
||||
fs.fsync(fd,resolve);
|
||||
stream.write(content,'utf8',function() {
|
||||
fs.fsync(fd,function(err) {
|
||||
if (err) {
|
||||
log.warn(log._("storage.localfilesystem.fsync-fail",{path: path, message: err.toString()}));
|
||||
}
|
||||
stream.end(resolve);
|
||||
});
|
||||
});
|
||||
});
|
||||
stream.on('error',function(err) {
|
||||
|
Loading…
Reference in New Issue
Block a user