Quietly handle ranking gsetting change after app update

Do not print errors for everyone who updates Clapper from 0.3.0 version.
How plugin ranking is stored in gsettings changed. Instead reset it quietly
into new defaults to avoid problems.

Also since now GstClapper API sets some default ranks based on installed
GStreamer version, hopefully this ranking will be only an edge case for
people who want to experiment or need to test/debug some GStreamer plugin.
This commit is contained in:
Rafał Dzięgiel
2021-08-27 13:30:08 +02:00
parent ad563d16d0
commit 2686c2ca03

View File

@@ -97,18 +97,24 @@ class ClapperPlayer extends GstClapper.Clapper
set_all_plugins_ranks() set_all_plugins_ranks()
{ {
let data = {}; let data = {};
let hadErr = false;
/* Set empty plugin list if someone messed it externally */ /* Set empty plugin list if someone messed it externally */
try { try {
data = JSON.parse(settings.get_string('plugin-ranking')); data = JSON.parse(settings.get_string('plugin-ranking'));
if(Array.isArray(data)) { if(Array.isArray(data)) {
data = {}; data = {};
throw new Error('plugin ranking data is not an object'); hadErr = true;
} }
} }
catch(err) { catch(err) {
debug(err); debug(err);
hadErr = true;
}
if(hadErr) {
settings.set_string('plugin-ranking', "{}"); settings.set_string('plugin-ranking', "{}");
debug('restored plugin ranking to defaults');
} }
for(let plugin of Object.keys(data)) for(let plugin of Object.keys(data))