diff --git a/src/io/serialize.c b/src/io/serialize.c index 1905a1c..60e45bc 100644 --- a/src/io/serialize.c +++ b/src/io/serialize.c @@ -57,7 +57,7 @@ index_descriptor_t read_index_descriptor(char *path) { int fd = open(path, O_RDONLY); if (fd == -1) { - LOG_FATAL("serialize.c", "Invalid/corrupt index (Could not find descriptor)\n") + LOG_FATALF("serialize.c", "Invalid/corrupt index (Could not find descriptor): %s: %s\n", path ,strerror(errno)) } char *buf = malloc(info.st_size + 1); diff --git a/src/main.c b/src/main.c index a95bf2e..2cc7b50 100644 --- a/src/main.c +++ b/src/main.c @@ -75,9 +75,17 @@ void sist2_scan(scan_args_t *args) { DIR *dir = opendir(args->incremental); if (dir == NULL) { - perror("opendir"); - return; + LOG_FATALF("main.c", "Could not open original index for incremental scan: %s", strerror(errno)) } + + char descriptor_path[PATH_MAX]; + snprintf(descriptor_path, PATH_MAX, "%s/descriptor.json", args->incremental); + index_descriptor_t original_desc = read_index_descriptor(descriptor_path); + + if (strcmp(original_desc.version, Version) != 0) { + LOG_FATALF("main.c", "Version mismatch! Index is %s but executable is %s/%s", original_desc.version, Version, INDEX_VERSION_EXTERNAL) + } + struct dirent *de; while ((de = readdir(dir)) != NULL) { if (strncmp(de->d_name, "_index_", sizeof("_index_") - 1) == 0) { @@ -140,9 +148,7 @@ void sist2_index(index_args_t *args) { LOG_DEBUGF("main.c", "descriptor version %s (%s)", desc.version, desc.type) if (strcmp(desc.version, Version) != 0 && strcmp(desc.version, INDEX_VERSION_EXTERNAL) != 0) { - fprintf(stderr, "Version mismatch! Index is %s but executable is %s/%s\n", - desc.version, Version, INDEX_VERSION_EXTERNAL); - return; + LOG_FATALF("main.c", "Version mismatch! Index is %s but executable is %s/%s", desc.version, Version, INDEX_VERSION_EXTERNAL) } DIR *dir = opendir(args->index_path);