diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2020-02-24 21:01:58 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2020-02-24 21:01:58 +0000 |
commit | 14286b381b12034140768800c7ba10baa7c3b334 (patch) | |
tree | d49625f2f604aab98812908175e2433ce5c6b166 | |
parent | 5dd1a81f9c97d852faa54e0d96482b69739fe8dc (diff) | |
download | netsurf-14286b381b12034140768800c7ba10baa7c3b334.tar.gz netsurf-14286b381b12034140768800c7ba10baa7c3b334.tar.bz2 |
fs_backing_store: Remove cache on failure to init
If we fail to init the control file for reasons other than it
not being found, we blow away the cache in its entirety and then
try again. We warn if the removal fails, but carry on regardless
since right now the worst that'll happen is that we'll end up
with more on disk than we know about in the cache.
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
-rw-r--r-- | content/fs_backing_store.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/content/fs_backing_store.c b/content/fs_backing_store.c index ff1c26559..458866c62 100644 --- a/content/fs_backing_store.c +++ b/content/fs_backing_store.c @@ -62,7 +62,7 @@ #define DEFAULT_ENTRY_SIZE 16 /** Backing store file format version */ -#define CONTROL_VERSION 201 +#define CONTROL_VERSION 202 /** Number of milliseconds after a update before control data maintenance is performed */ #define CONTROL_MAINT_TIME 10000 @@ -1461,8 +1461,22 @@ initialise(const struct llcache_store_parameters *parameters) /* read store control and create new if required */ ret = read_control(newstate); if (ret != NSERROR_OK) { - NSLOG(netsurf, ERROR, "read control failed %s", - messages_get_errorcode(ret)); + if (ret == NSERROR_NOT_FOUND) { + NSLOG(netsurf, INFO, "cache control file not found, making fresh"); + } else { + NSLOG(netsurf, ERROR, "read control failed %s", + messages_get_errorcode(ret)); + ret = netsurf_recursive_rm(newstate->path); + if (ret != NSERROR_OK) { + NSLOG(netsurf, WARNING, "Error `%s` while removing `%s`", + messages_get_errorcode(ret), newstate->path); + NSLOG(netsurf, WARNING, "Unable to clean up partial cache state."); + NSLOG(netsurf, WARNING, "Funky behaviour may ensue."); + } else { + NSLOG(netsurf, INFO, "Successfully removed old cache from `%s`", + newstate->path); + } + } ret = write_control(newstate); if (ret == NSERROR_OK) { unlink_entries(newstate); |