Check if the presets exist when going to get them
- Return empty object if no preset file is found
This commit is contained in:
@@ -17,7 +17,7 @@ function writePresets(presets, callback = undefined) {
|
||||
// Error checking
|
||||
if (err) throw err;
|
||||
log.DEBUG("Write Complete");
|
||||
if (callback) callback()
|
||||
if (callback) callback(); else return
|
||||
});
|
||||
}
|
||||
|
||||
@@ -71,8 +71,9 @@ function convertFrequencyToHertz(frequency){
|
||||
*/
|
||||
exports.getPresets = function getPresets() {
|
||||
const presetDir = path.resolve("./config/radioPresets.json");
|
||||
log.DEBUG(`Getting presets from directory: '${presetDir}'`);
|
||||
return JSON.parse(fs.readFileSync(presetDir));
|
||||
log.DEBUG(`Getting presets from directory: '${presetDir}'`);
|
||||
if (fs.existsSync(presetDir)) return JSON.parse(fs.readFileSync(presetDir));
|
||||
else return {};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user