Browse Source

backup corrupted board data

dev_h
Ophir LOJKINE 6 years ago
parent
commit
c5a44fda5d
1 changed files with 8 additions and 0 deletions
  1. 8
    0
      server/boardData.js

+ 8
- 0
server/boardData.js View File

233
 				console.error("Unable to read history from " + boardData.file + ". The following error occured: " + e);
233
 				console.error("Unable to read history from " + boardData.file + ". The following error occured: " + e);
234
 				log('empty board creation', { 'board': boardData.name });
234
 				log('empty board creation', { 'board': boardData.name });
235
 				boardData.board = {}
235
 				boardData.board = {}
236
+				if (data) {
237
+					// There was an error loading the board, but some data was still read
238
+					var backupFileName = boardData.file + '.' + new Date().toISOString() + '.bak';
239
+					log("Writing the corrupted file to " + backupFileName);
240
+					fs.writeFile(backupFileName, data, function (err) {
241
+						if (err) log("Error writing " + backupFileName + ": " + err);
242
+					});
243
+				}
236
 			}
244
 			}
237
 			accept(boardData);
245
 			accept(boardData);
238
 		});
246
 		});

Loading…
Cancel
Save