From f4e0f6279c1c8e49cc899dbe844dad50366a4d98 Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Wed, 9 Oct 2019 23:11:19 +0200 Subject: [PATCH] Put :cleardata dataType before timespan. --- CHANGELOG.md | 4 +-- doc/vimb.1 | 71 +++++++++++++++++++++++++++------------------------- src/ex.c | 18 +++++++------ 3 files changed, 49 insertions(+), 44 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3edb230..50792b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,14 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] ### Added -* `:cleardata [timeSpan] [listOfDataTypes]` command to clear various types of +* `:cleardata [listOfDataTypes] [timeSpan]` command to clear various types of stored website data modified in the last _timeSpan_. ### Changed ### Fixed ### Removed * `:clearcache` was removed in favor of more advanced `:cleardata` command. The previous behaviour of `:clearcache` could be replaces by - `:cleardata - memory-cache,disk-cache`. + `:cleardata memory-cache,disk-cache`. ## [3.5.0] - 2019-07-29 ### Added diff --git a/doc/vimb.1 b/doc/vimb.1 index 8b7ffa9..3fb827d 100644 --- a/doc/vimb.1 +++ b/doc/vimb.1 @@ -807,42 +807,15 @@ Example: .EE .SS Misc .TP -.BI ":cl[eardata] [" timespan "] [" dataTypes "]" -Asynchronously clears the website data of the given list of\fIdataTypes\fP +.BI ":cl[eardata] [" dataTypes "] [" timespan "]" +Asynchronously clears the website data of the given list of \fIdataTypes\fP modified in the past \fItimespan\fP. -If \fItimespan\fP is 0, all website data will be removed. +Note that the \fIdataTypes\fP must not contain spaces. +If \fItimespan\fP is not given, all website data will be removed. Note that this effects all running instances of vimb. .RS .PP .PD 0 -The \fItimespan\fP is given as sequence of '[multiplier]\fIunit\fP' tupels. -with following units. -.TP -.B y -year (365 days) -.TP -.B w -week (7 days) -.TP -.B d -day -.TP -.B h -hour -.TP -.B m -minute -.TP -.B s -second -.TP -.B - -can be used to clear data without timespan restriction -.PD -.RE -.RS -.PP -.PD 0 The \fIdataTypes\fP is a comma separated list of following types. .TP .B memory-cache @@ -872,16 +845,46 @@ given. .TP .B hsts-cache HTTP Strict Transport Security cache. -.sp +.TP +.B - +Can be used to clear all known data types in case a \fItimespan\fP is used. +.PD +.RE +.RS +.PP +.PD 0 +The \fItimespan\fP is given as sequence of '[multiplier]\fIunit\fP' tupels +with following units. +.TP +.B y +year (365 days) +.TP +.B w +week (7 days) +.TP +.B d +day +.TP +.B h +hour +.TP +.B m +minute +.TP +.B s +second +.PD .PP .I Example: .PD 0 .IP ":cleardata" to clear all known website data types without any timespan restriction. -.IP ":cleardata - local-storage,session-storage,cookies" +.IP ":cleardata - 5m" +to clear all known website data types modified in the last 5 minutes. +.IP ":cleardata local-storage,session-storage,cookies" to completely clear the cookies, local- and session-storage without time restrictions. -.IP ":cleardata 2d4h disk-cache" +.IP ":cleardata disk-cache 2d4h" to clear the disk cache that was modified in the past two days and four hours. .PD .RE diff --git a/src/ex.c b/src/ex.c index 9a3d224..4ed310e 100644 --- a/src/ex.c +++ b/src/ex.c @@ -855,7 +855,7 @@ static void on_eval_script_finished(GDBusProxy *proxy, GAsyncResult *result, Cli } /** - * Clear website data by ':cleardata {time} {dataTypeList}'. + * Clear website data by ':cleardata {dataTypeList} {timespan}'. */ static VbCmdResult ex_cleardata(Client *c, const ExArg *arg) { @@ -864,13 +864,8 @@ static VbCmdResult ex_cleardata(Client *c, const ExArg *arg) VbCmdResult result = CMD_SUCCESS; GTimeSpan timespan = 0; - if (arg->lhs->len) { - timespan = util_string_to_timespan(arg->lhs->str); - } - if (!arg->rhs->len) { - /* No special type given - clear all known types. */ - data_types = WEBKIT_WEBSITE_DATA_ALL; - } else { + /* Parse the left hand side if this is available and not '-' */ + if (arg->lhs->len && strcmp(arg->lhs->str, "-") != 0) { GString *str; char **types; char *value; @@ -919,6 +914,13 @@ static VbCmdResult ex_cleardata(Client *c, const ExArg *arg) } g_string_free(str, TRUE); g_strfreev(types); + } else { + /* No special type or '-' given - clear all known types. */ + data_types = WEBKIT_WEBSITE_DATA_ALL; + } + + if (arg->rhs->len) { + timespan = util_string_to_timespan(arg->rhs->str); } manager = webkit_web_context_get_website_data_manager(webkit_web_view_get_context(c->webview)); webkit_website_data_manager_clear(manager, data_types, timespan, NULL, NULL, NULL); -- 2.20.1