Put :cleardata dataType before timespan.
authorDaniel Carl <danielcarl@gmx.de>
Wed, 9 Oct 2019 21:11:19 +0000 (23:11 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Wed, 9 Oct 2019 21:11:19 +0000 (23:11 +0200)
CHANGELOG.md
doc/vimb.1
src/ex.c

index 3edb230..50792b9 100644 (file)
@@ -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
index 8b7ffa9..3fb827d 100644 (file)
@@ -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
index 9a3d224..4ed310e 100644 (file)
--- 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);