mirror of
https://github.com/lovasoa/whitebophir
synced 2024-11-14 16:27:13 +00:00
backup corrupted board data
This commit is contained in:
parent
6d56d7b877
commit
c5a44fda5d
1 changed files with 8 additions and 0 deletions
|
@ -233,6 +233,14 @@ BoardData.load = function loadBoard(name) {
|
|||
console.error("Unable to read history from " + boardData.file + ". The following error occured: " + e);
|
||||
log('empty board creation', { 'board': boardData.name });
|
||||
boardData.board = {}
|
||||
if (data) {
|
||||
// There was an error loading the board, but some data was still read
|
||||
var backupFileName = boardData.file + '.' + new Date().toISOString() + '.bak';
|
||||
log("Writing the corrupted file to " + backupFileName);
|
||||
fs.writeFile(backupFileName, data, function (err) {
|
||||
if (err) log("Error writing " + backupFileName + ": " + err);
|
||||
});
|
||||
}
|
||||
}
|
||||
accept(boardData);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue