diff options
author | William Wilgus <wilgus.william@gmail.com> | 2021-08-02 01:40:18 -0400 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2021-08-03 00:31:10 +0000 |
commit | 3b6c3d769fc944a09a10f40cdfc1a29f908ab882 (patch) | |
tree | e68d4ac395ad7efda997158de91deacd5d02ab0d | |
parent | 0501af8b063a9c4aa79a008566810bed7deb5502 (diff) |
open_plugins bugfix failure to save
if you added a plugin through the core settings and then used the shortcut
immediately the entry would never get flushed to disk
Change-Id: I62e876bbf0a8fa96acba1cc2582e2563401547f1
-rw-r--r-- | apps/open_plugin.c | 17 | ||||
-rw-r--r-- | apps/root_menu.c | 4 |
2 files changed, 12 insertions, 9 deletions
diff --git a/apps/open_plugin.c b/apps/open_plugin.c index 8453b3976d..7b5513a92b 100644 --- a/apps/open_plugin.c +++ b/apps/open_plugin.c @@ -49,7 +49,7 @@ static inline void op_clear_entry(struct open_plugin_entry_t *entry) } } -static int op_update_dat(struct open_plugin_entry_t *entry) +static int op_update_dat(struct open_plugin_entry_t *entry, bool clear) { int fd, fd1; uint32_t hash; @@ -79,7 +79,9 @@ static int op_update_dat(struct open_plugin_entry_t *entry) rename(OPEN_PLUGIN_DAT ".tmp", OPEN_PLUGIN_DAT); - op_clear_entry(&open_plugin_entry); + if (clear) + op_clear_entry(&open_plugin_entry); + return 0; } @@ -106,7 +108,7 @@ uint32_t open_plugin_add_path(const char *key, const char *plugin, const char *p if(open_plugin_entry.hash != hash) { /* the entry in ram needs saved */ - op_update_dat(&open_plugin_entry); + op_update_dat(&open_plugin_entry, true); } if (plugin) @@ -182,9 +184,9 @@ static int open_plugin_hash_get_entry(uint32_t hash, if (hash != 0) { if(entry->hash == hash) /* hasn't been flushed yet? */ - return 0; + return -2; else - op_update_dat(&open_plugin_entry); + op_update_dat(&open_plugin_entry, true); } int fd = open(dat_file, O_RDONLY); @@ -232,7 +234,8 @@ int open_plugin_run(const char *key) const char *path; const char *param; - open_plugin_get_entry(key, &open_plugin_entry); + if (open_plugin_get_entry(key, &open_plugin_entry) == -2) /* entry needs flushed */ + op_update_dat(&open_plugin_entry, false); path = open_plugin_entry.path; param = open_plugin_entry.param; @@ -250,7 +253,7 @@ int open_plugin_run(const char *key) void open_plugin_cache_flush(void) { - op_update_dat(&open_plugin_entry); + op_update_dat(&open_plugin_entry, true); } #endif /* ndef __PCTOOL__ */ diff --git a/apps/root_menu.c b/apps/root_menu.c index 62014b619d..2eab43f504 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c @@ -848,7 +848,7 @@ void root_menu(void) } } - open_plugin_get_entry(key, &open_plugin_entry); + bool flush = (open_plugin_get_entry(key, &open_plugin_entry) == -2); char *path = open_plugin_entry.path; char *param = open_plugin_entry.param; if (param[0] == '\0') @@ -856,7 +856,7 @@ void root_menu(void) next_screen = load_plugin_screen(path, param); - if (next_screen != GO_TO_PLUGIN) + if (!flush && next_screen != GO_TO_PLUGIN) open_plugin_add_path(NULL, NULL, NULL); /* shortcuts may take several trips through the GO_TO_PLUGIN case |