[PATCH] Add NODISKCACHE option to disable the disk cache at compile-time

From: Nick White <git_AT_njw.name>
Date: Mon, 13 Apr 2015 22:58:04 +0100

This is useful as older versions of libwebkit don't have the
functionality, so surf wouldn't compile on those systems.
---
 config.mk |    1 +
 surf.c    |    8 ++++++++
 2 files changed, 9 insertions(+)
diff --git a/config.mk b/config.mk
index e49fa24..47f46a2 100644
--- a/config.mk
+++ b/config.mk
_AT_@ -18,6 +18,7 @@ INCS = -I. -I/usr/include -I${X11INC} ${GTKINC}
 LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${GTKLIB} -lgthread-2.0
 
 # flags
+#CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE -DNODISKCACHE
 CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE
 CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
 LDFLAGS = -g ${LIBS}
diff --git a/surf.c b/surf.c
index 87c10ef..9d8b659 100644
--- a/surf.c
+++ b/surf.c
_AT_@ -107,7 +107,9 @@ static char pagestat[3];
 static GTlsDatabase *tlsdb;
 static int policysel = 0;
 static char *stylefile = NULL;
+#ifndef NODISKCACHE
 static SoupCache *diskcache = NULL;
+#endif
 
 static void addaccelgroup(Client *c);
 static void beforerequest(WebKitWebView *w, WebKitWebFrame *f,
_AT_@ -312,10 +314,12 @@ buttonrelease(WebKitWebView *web, GdkEventButton *e, Client *c) {
 
 static void
 cleanup(void) {
+	#ifndef NODISKCACHE
 	if(diskcache) {
 		soup_cache_flush(diskcache);
 		soup_cache_dump(diskcache);
 	}
+	#endif
 	while(clients)
 		destroyclient(clients);
 	g_free(cookiefile);
_AT_@ -735,10 +739,12 @@ loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c) {
 	case WEBKIT_LOAD_FINISHED:
 		c->progress = 100;
 		updatetitle(c);
+		#ifndef NODISKCACHE
 		if(diskcache) {
 			soup_cache_flush(diskcache);
 			soup_cache_dump(diskcache);
 		}
+		#endif NODISKCACHE
 		break;
 	default:
 		break;
_AT_@ -1251,12 +1257,14 @@ setup(void) {
 					cookiepolicy_get())));
 
 	/* disk cache */
+	#ifndef NODISKCACHE
 	if(enablediskcache) {
 		diskcache = soup_cache_new(cachefolder, SOUP_CACHE_SINGLE_USER);
 		soup_cache_set_max_size(diskcache, diskcachebytes);
 		soup_cache_load(diskcache);
 		soup_session_add_feature(s, SOUP_SESSION_FEATURE(diskcache));
 	}
+	#endif
 
 	/* ssl */
 	tlsdb = g_tls_file_database_new(cafile, &error);
-- 
1.7.10.4
--PNTmBPCT7hxwcZjr--
Received on Mon Sep 17 2001 - 00:00:00 CEST

This archive was generated by hypermail 2.3.0 : Tue Apr 14 2015 - 00:36:04 CEST