Add :clearcache command.
authorDaniel Carl <danielcarl@gmx.de>
Wed, 24 May 2017 19:04:32 +0000 (21:04 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Wed, 24 May 2017 19:04:32 +0000 (21:04 +0200)
This allows to discard all caches currently used by webkit.

doc/vimb.1
src/ex.c

index 70c9272..306d0f1 100644 (file)
@@ -630,6 +630,10 @@ queue.
 Removes all entries from queue.
 .SS Misc
 .TP
+.B :cl[earcache]
+Clears all resources currently cached by webkit.
+Note that this effects all running instances of vimb.
+.TP
 .BI ":sh[ellcmd] " cmd
 Runs the given shell \fIcmd\fP syncron and print the output into inputbox.
 The following patterns in \fIcmd\fP are expanded: '~username', '~/', '$VAR'
index 3660ec7..d924ae0 100644 (file)
--- a/src/ex.c
+++ b/src/ex.c
@@ -48,6 +48,7 @@ typedef enum {
     EX_BMR,
     EX_EVAL,
     EX_HARDCOPY,
+    EX_CLEARCACHE,
     EX_CMAP,
     EX_CNOREMAP,
     EX_HANDADD,
@@ -129,6 +130,7 @@ static VbCmdResult execute(Client *c, const ExArg *arg);
 static VbCmdResult ex_bookmark(Client *c, const ExArg *arg);
 static VbCmdResult ex_eval(Client *c, const ExArg *arg);
 static void on_eval_script_finished(GDBusProxy *proxy, GAsyncResult *result, Client *c);
+static VbCmdResult ex_clearcache(Client *c, const ExArg *arg);
 static VbCmdResult ex_hardcopy(Client *c, const ExArg *arg);
 static VbCmdResult ex_map(Client *c, const ExArg *arg);
 static VbCmdResult ex_unmap(Client *c, const ExArg *arg);
@@ -164,6 +166,7 @@ static ExInfo commands[] = {
     {"cmap",             EX_CMAP,        ex_map,        EX_FLAG_LHS|EX_FLAG_CMD},
     {"cnoremap",         EX_CNOREMAP,    ex_map,        EX_FLAG_LHS|EX_FLAG_CMD},
     {"cunmap",           EX_CUNMAP,      ex_unmap,      EX_FLAG_LHS},
+    {"clearcache",       EX_CLEARCACHE,  ex_clearcache, EX_FLAG_NONE},
     {"hardcopy",         EX_HARDCOPY,    ex_hardcopy,   EX_FLAG_NONE},
     {"handler-add",      EX_HANDADD,     ex_handlers,   EX_FLAG_RHS},
     {"handler-remove",   EX_HANDREM,     ex_handlers,   EX_FLAG_RHS},
@@ -822,6 +825,12 @@ static void on_eval_script_finished(GDBusProxy *proxy, GAsyncResult *result, Cli
     }
 }
 
+static VbCmdResult ex_clearcache(Client *c, const ExArg *arg)
+{
+    webkit_web_context_clear_cache(webkit_web_context_get_default());
+    return CMD_SUCCESS;
+}
+
 static VbCmdResult ex_hardcopy(Client *c, const ExArg *arg)
 {
     WebKitPrintOperation *op   = webkit_print_operation_new(c->webview);