From 7551be3194926ad5382c3291887188b27574ffa5 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sat, 9 Dec 2006 18:23:41 +0200 Subject: [PATCH] Bug 887: save_cookies ignores cookies_dirty if requested by the user. --- src/cookies/cookies.c | 12 ++++++++---- src/cookies/cookies.h | 2 +- src/cookies/dialogs.c | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/cookies/cookies.c b/src/cookies/cookies.c index 2f0530dd4..4c7c32a1c 100644 --- a/src/cookies/cookies.c +++ b/src/cookies/cookies.c @@ -802,7 +802,7 @@ static void resave_cookies_bottom_half(void *always_null) { if (get_cookies_save() && get_cookies_resave()) - save_cookies(); /* checks cookies_dirty */ + save_cookies(0); /* checks cookies_dirty */ } /* Note that the cookies have been modified, and register a bottom @@ -822,14 +822,18 @@ set_cookies_dirty(void) register_bottom_half(resave_cookies_bottom_half, NULL); } +/* @interactive is 1 if the user told ELinks to save cookies, or 0 if + * ELinks decided that on its own. In the latter case, this function + * does not save the cookies if it thinks the file is already up to + * date. */ void -save_cookies(void) { +save_cookies(int interactive) { struct cookie *c; unsigned char *cookfile; struct secure_save_info *ssi; time_t now; - if (cookies_nosave || !elinks_home || !cookies_dirty + if (cookies_nosave || !elinks_home || !(cookies_dirty || interactive) || get_cmd_opt_bool("anonymous")) return; @@ -880,7 +884,7 @@ done_cookies(struct module *module) free_list(c_domains); if (!cookies_nosave && get_cookies_save()) - save_cookies(); + save_cookies(0); free_cookies_list(&cookies); free_cookies_list(&cookie_queries); diff --git a/src/cookies/cookies.h b/src/cookies/cookies.h index be60ae268..bf67ae7de 100644 --- a/src/cookies/cookies.h +++ b/src/cookies/cookies.h @@ -44,7 +44,7 @@ void done_cookie(struct cookie *); void delete_cookie(struct cookie *); void set_cookie(struct uri *, unsigned char *); void load_cookies(void); -void save_cookies(void); +void save_cookies(int interactive); void set_cookies_dirty(void); /* Note that the returned value points to a static structure and thus the diff --git a/src/cookies/dialogs.c b/src/cookies/dialogs.c index 3ff9183c3..9d6bdf219 100644 --- a/src/cookies/dialogs.c +++ b/src/cookies/dialogs.c @@ -465,7 +465,7 @@ push_add_server_button(struct dialog_data *dlg_data, struct widget_data *button) static widget_handler_status_T push_save_button(struct dialog_data *dlg_data, struct widget_data *button) { - save_cookies(); + save_cookies(1); return EVENT_PROCESSED; }