fix: Fix removal of entries in account file
Commit81f92f1feintroduced a selective update mechanism to _accounts_save() to prevent overwrites when running multiple instances by only modifying the specific account being saved. Commit 5c484c fixed a problem with that commit regarding empty accounts. It turns there was another bug introduced: The new implementation only set the keys that existed in memory. So removal of keys was not possible anymore. Fixes:81f92f1fedRef:5c484c26edSigned-off-by: Michael Vetter <jubalh@iodoru.org>
This commit is contained in:
@@ -75,6 +75,17 @@ _accounts_save(const char* account_name)
|
||||
auto_gchar gchar* sanitized = _sanitize_account_name(account_name);
|
||||
|
||||
if (_accounts_has_group(sanitized)) {
|
||||
// Remove keys from file that are no longer in memory
|
||||
gsize nkeys_disk;
|
||||
auto_gcharv gchar** keys_disk = g_key_file_get_keys(current.keyfile, sanitized, &nkeys_disk, NULL);
|
||||
if (keys_disk) {
|
||||
for (gsize j = 0; j < nkeys_disk; ++j) {
|
||||
if (!g_key_file_has_key(accounts_prof_keyfile.keyfile, sanitized, keys_disk[j], NULL)) {
|
||||
g_key_file_remove_key(current.keyfile, sanitized, keys_disk[j], NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gsize nkeys;
|
||||
auto_gcharv gchar** keys = g_key_file_get_keys(accounts_prof_keyfile.keyfile, sanitized, &nkeys, NULL);
|
||||
if (keys) {
|
||||
|
||||
Reference in New Issue
Block a user