Skip to content

Commit

Permalink
Fixed saving while having a category selected
Browse files Browse the repository at this point in the history
  • Loading branch information
omgftw committed May 26, 2018
1 parent c4a5a29 commit 66ba687
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ node_modules
build
dist
saves
settings.json
DarkSoulsSaveManager
settings.json*
debug.log
*.zip
25 changes: 23 additions & 2 deletions app/core/coreService.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,17 @@
return;
}

filePath = filePath || svc.data.settings.saveFileLocation, backupFileName;
filePath = filePath || svc.data.settings.saveFileLocation;
fs.copyFileSync(filePath, backupFileName);
var fileName = saveName;
var type = 'manual';
if (opts && opts.type) type = opts.type;
var save = new Save(fileName, backupFileName, svc.data.settings.selectedCategory, type);
svc.data.saves.push(save);

// Remove oldest autosaves that are higher then the max autosave count
// svc.cleanupAutosaves();

svc.saveSettings();
if (!filePath) {
svc.showSuccessToast(messages.backupCreated)
Expand Down Expand Up @@ -268,7 +271,7 @@
svc.showSuccessToast(messages.backupRestored);
return;
}

svc.showSuccessToast(messages.backupDestBackupNotFound);
};

Expand Down Expand Up @@ -384,6 +387,24 @@
svc.stopAutosave();
}
}, true);

// svc.cleanupAutosaves = function () {
// if (!svc.data.settings.autosaveMaxLimit) return;
// if (svc.data.saves.length === 0) return;
// var autosaves = _.filter(svc.data.saves, x => x.type === 'auto');
// if (autosaves.length > svc.data.settings.autosaveMaxCount) {
// var toRemove = _(autosaves).sortBy(x => x.time).reverse().slice(parseInt(svc.data.settings.autosaveMaxCount)).value();
// for (var i = 0; i < toRemove.length; i++) {
// var currentSave = toRemove[i];
// if (fs.existsSync(currentSave.path))
// fs.unlinkSync(currentSave.path);
// if (!fs.existsSync(currentSave.path)) {
// svc.data.saves.splice(currentSave, 1);
// }
// }
// console.log(toRemove);
// }
// };
};


Expand Down
2 changes: 1 addition & 1 deletion app/main/mainController.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
};

vm.createBackup = function () {
core.createBackup(vm.settings.selectedCategory);
core.createBackup();
vm.categorySelect();
};

Expand Down

0 comments on commit 66ba687

Please sign in to comment.