From 999107eb4383f5f7b41e784e8faa719103608a16 Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 7 Aug 2014 12:34:26 +1000 Subject: [PATCH] ckdb - create the reload 'begin' filename if not found --- src/ckdb.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/ckdb.c b/src/ckdb.c index 1178d564..1f13c677 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -5343,8 +5343,10 @@ static bool reload_from(tv_t *start); static bool reload() { char buf[DATE_BUFSIZ+1]; + char *filename; K_ITEM *ccl; tv_t start; + FILE *fp; bool ok; tv_to_buf(&(dbstatus.oldest_sharesummary_firstshare_n), buf, sizeof(buf)); @@ -5383,6 +5385,21 @@ static bool reload() if (start.tv_sec < DATE_BEGIN) { start.tv_sec = DATE_BEGIN; start.tv_usec = 0L; + filename = rotating_filename(restorefrom, start.tv_sec); + fp = fopen(filename, "r"); + if (fp) + fclose(fp); + else { + mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; + int fd = open(filename, O_CREAT|O_RDONLY, mode); + if (fd == -1) { + int ern = errno; + quithere(1, "Couldn't create '%s' (%d) %s", + filename, ern, strerror(ern)); + close(fd); + } + } + free(filename); } ok = reload_from(&start);