From c87bbec03cee711cb0ce348b7d955c7711d69d69 Mon Sep 17 00:00:00 2001 From: josch Date: Mon, 19 Jan 2015 17:18:10 +0100 Subject: [PATCH] fuse: when the hashtable fails to load, start a new one instead of failing --- fuse/main.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/fuse/main.c b/fuse/main.c index 8d43cf3..effe5c5 100644 --- a/fuse/main.c +++ b/fuse/main.c @@ -312,25 +312,27 @@ static void open_hashtbl(const char *dircache, const char *filecache, *tree = folder_tree_load(fp, filecache); - if (*tree == NULL) { - fprintf(stderr, "cannot load directory hashtable\n"); - exit(1); - } - fclose(fp); - // TODO: make the maximum cache size configurable - // size is given in bytes and current default is 1 GiB - folder_tree_cleanup_filecache(*tree, 1073741824); + if (*tree != NULL) { - folder_tree_update(*tree, conn, false); - } else { - // file doesn't exist - fprintf(stderr, "creating new hashtable\n"); - *tree = folder_tree_create(filecache); + // TODO: make the maximum cache size configurable + // size is given in bytes and current default is 1 GiB + folder_tree_cleanup_filecache(*tree, 1073741824); - folder_tree_rebuild(*tree, conn); + folder_tree_update(*tree, conn, false); + + return; + } + + fprintf(stderr, "cannot load directory hashtable - starting" + " a new one\n"); } + // file doesn't exist or is corrupt + fprintf(stderr, "creating new hashtable\n"); + *tree = folder_tree_create(filecache); + + folder_tree_rebuild(*tree, conn); //folder_tree_housekeep(tree);