Skip to content

Commit

Permalink
delete old overlay first
Browse files Browse the repository at this point in the history
  • Loading branch information
ebiggz committed Aug 9, 2017
1 parent 6e2428d commit 83b3611
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
21 changes: 20 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,32 @@ function createWindow () {
dataAccess.makeDirInUserData("/user-settings/logs");
});

var deleteFolderRecursive = function(path) {
if(path == null || path.toString().trim() == "/" || path.toString().trim() == "") { return; }
if( fs.existsSync(path) ) {
fs.readdirSync(path).forEach(function(file,index){
var curPath = path + "/" + file;
if(fs.lstatSync(curPath).isDirectory()) { // recurse
deleteFolderRecursive(curPath);
} else { // delete file
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(path);
}
};


var overlayFolderExists = dataAccess.userDataPathExistsSync("/overlay/");
var appVersion = electron.app.getVersion();
if(!overlayFolderExists || settings.getOverlayVersion() !== appVersion) {


var source = dataAccess.getPathInWorkingDir("/resources/overlay");
var destination = dataAccess.getPathInUserData("/overlay");
var destination = dataAccess.getPathInUserData("/overlay");

deleteFolderRecursive(destination);
console.log("Deleting old overlay folder");
ncp(source, destination, { clobber: true }, function (err) {
if (err) {
console.log("Error copying Overlay folder to user data!");
Expand Down
Loading

0 comments on commit 83b3611

Please sign in to comment.