fix: Fix removal of entries in account file

Commit 81f92f1fe introduced 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: 81f92f1fed
Ref: 5c484c26ed
Signed-off-by: Michael Vetter <jubalh@iodoru.org>
This commit is contained in:
Michael Vetter
2026-04-02 20:36:14 +02:00
parent c9a3823f13
commit 8675f7be0c
5 changed files with 35 additions and 0 deletions

View File

@@ -384,7 +384,9 @@ cmd_connect(ProfWin* window, const char* const command, gchar** args)
// use eval_password if set
} else if (account->eval_password) {
ui_suspend();
gboolean res = account_eval_password(account);
ui_resume();
ui_resize();
if (res) {
conn_status = cl_ev_connect_account(account);

View File

@@ -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) {

View File

@@ -171,6 +171,18 @@ ui_reset_idle_time(void)
g_timer_start(ui_idle_time);
}
void
ui_suspend(void)
{
endwin();
}
void
ui_resume(void)
{
refresh();
}
void
ui_resize(void)
{

View File

@@ -36,6 +36,8 @@
// core UI
void ui_init(void);
void ui_suspend(void);
void ui_resume(void);
void ui_load_colours(void);
void ui_update(void);
void ui_redraw(void);

View File

@@ -62,6 +62,14 @@ ui_init(void)
{
}
void
ui_suspend(void)
{
}
void
ui_resume(void)
{
}
void
ui_load_colours(void)
{
}