Fix getting trolled by partial autosaves (.tmp.zip)

This commit is contained in:
Danielv123 committed 2017-03-02 13:47:02 +01:00
1 parent 36bfd6450b
commit d4968e0894
2 files changed
+6 -3

No files matched your search

+5 -3
View File
@@ -8,6 +8,7 @@ var request = require("request")
var ncp = require('ncp').ncp; var ncp = require('ncp').ncp;
var Rcon = require('simple-rcon'); var Rcon = require('simple-rcon');
var hashFiles = require('hash-files'); var hashFiles = require('hash-files');
var findRemoveSync = require('find-remove');
// require config.json // require config.json
var config = require('./config'); var config = require('./config');
@@ -162,11 +163,12 @@ write-data=__PATH__executable__/../../../instances/" + instance + "\r\n\
} else { } else {
process.exit(1) process.exit(1)
} }
console.log("Deleting .tmp.zip files");
findRemoveSync(instancedirectory + "/saves", {extensions: ['.tmp.zip']})
console.log("Deleting logs"); console.log("Deleting logs");
// clean old log file to avoid crash // clean old log file to avoid crash
// file exists, delete so we don't get in trouble // file exists, delete so we don't get in trouble
try { try {
fs.unlinkSync(instancedirectory+'/factorio-current.log') fs.unlinkSync(instancedirectory+'/factorio-current.log')
} catch (err){ } catch (err){
@@ -493,7 +495,7 @@ function instanceManagement() {
sadas = JSON.stringify(confirmedOrders) sadas = JSON.stringify(confirmedOrders)
confirmedOrders = []; confirmedOrders = [];
// send our RCON command with whatever we got // send our RCON command with whatever we got
client.exec("/silent-command remote.call('clusterio', 'importMany', '" + sadas + "')"); messageInterface("/silent-command remote.call('clusterio', 'importMany', '" + sadas + "')");
} }
}, 3000) }, 3000)
// COMBINATOR SIGNALS --------------------------------------------------------- // COMBINATOR SIGNALS ---------------------------------------------------------
@@ -510,7 +512,7 @@ function instanceManagement() {
} }
inventoryFrame["signal-unixtime"] = Math.floor(Date.now()/1000); inventoryFrame["signal-unixtime"] = Math.floor(Date.now()/1000);
// console.log("RCONing inventory! " + JSON.stringify(inventoryFrame)); // console.log("RCONing inventory! " + JSON.stringify(inventoryFrame));
client.exec("/silent-command remote.call('clusterio', 'receiveInventory', '" + JSON.stringify(inventoryFrame) + "')"); messageInterface("/silent-command remote.call('clusterio', 'receiveInventory', '" + JSON.stringify(inventoryFrame) + "')");
} }
}); });
}, 1000) }, 1000)
+1
View File
@@ -18,6 +18,7 @@
"child_process": "^1.0.2", "child_process": "^1.0.2",
"express": "^4.14.0", "express": "^4.14.0",
"express-fileupload": "0.0.6", "express-fileupload": "0.0.6",
"find-remove": "^1.0.0",
"follow-redirects": "^1.2.1", "follow-redirects": "^1.2.1",
"fs": "0.0.2", "fs": "0.0.2",
"fs-extra": "^1.0.0", "fs-extra": "^1.0.0",