mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
parent
9d4139085b
commit
f97f92c297
@ -122,6 +122,12 @@ function writeFile(path,content) {
|
||||
});
|
||||
}
|
||||
|
||||
function parseJSON(data) {
|
||||
if (data.charCodeAt(0) === 0xFEFF) {
|
||||
data = data.slice(1)
|
||||
}
|
||||
return JSON.parse(data);
|
||||
}
|
||||
|
||||
function readFile(path,backupPath,emptyResponse,type) {
|
||||
return when.promise(function(resolve) {
|
||||
@ -154,7 +160,7 @@ function readFile(path,backupPath,emptyResponse,type) {
|
||||
}
|
||||
}
|
||||
try {
|
||||
return resolve(JSON.parse(data));
|
||||
return resolve(parseJSON(data));
|
||||
} catch(parseErr) {
|
||||
log.warn(log._("storage.localfilesystem.invalid",{type:type}));
|
||||
return resolve(emptyResponse);
|
||||
@ -307,7 +313,7 @@ var localfilesystem = {
|
||||
fs.readFile(globalSettingsFile,'utf8',function(err,data) {
|
||||
if (!err) {
|
||||
try {
|
||||
return resolve(JSON.parse(data));
|
||||
return resolve(parseJSON(data));
|
||||
} catch(err2) {
|
||||
log.trace("Corrupted config detected - resetting");
|
||||
}
|
||||
@ -327,7 +333,7 @@ var localfilesystem = {
|
||||
fs.readFile(sessionsFile,'utf8',function(err,data){
|
||||
if (!err) {
|
||||
try {
|
||||
return resolve(JSON.parse(data));
|
||||
return resolve(parseJSON(data));
|
||||
} catch(err2) {
|
||||
log.trace("Corrupted sessions file - resetting");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user