Explorar el Código

backup corrupted board data

dev_h
Ophir LOJKINE hace 6 años
padre
commit
c5a44fda5d
Se han modificado 1 ficheros con 8 adiciones y 0 borrados
  1. 8
    0
      server/boardData.js

+ 8
- 0
server/boardData.js Ver fichero

@@ -233,6 +233,14 @@ BoardData.load = function loadBoard(name) {
233 233
 				console.error("Unable to read history from " + boardData.file + ". The following error occured: " + e);
234 234
 				log('empty board creation', { 'board': boardData.name });
235 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 245
 			accept(boardData);
238 246
 		});

Loading…
Cancelar
Guardar