mirror of
https://github.com/simon987/sist2.git
synced 2025-04-16 08:56:45 +00:00
Merge pull request #262 from yatli/fix_261
fix #261: inherit index id from base index when using incremental scan
This commit is contained in:
commit
6ec98046fa
19
src/main.c
19
src/main.c
@ -103,7 +103,7 @@ void sig_handler(int signum) {
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_dir(const char *dirpath) {
|
void init_dir(const char *dirpath, scan_args_t* args) {
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
snprintf(path, PATH_MAX, "%sdescriptor.json", dirpath);
|
snprintf(path, PATH_MAX, "%sdescriptor.json", dirpath);
|
||||||
|
|
||||||
@ -111,9 +111,18 @@ void init_dir(const char *dirpath) {
|
|||||||
strcpy(ScanCtx.index.desc.version, Version);
|
strcpy(ScanCtx.index.desc.version, Version);
|
||||||
strcpy(ScanCtx.index.desc.type, INDEX_TYPE_NDJSON);
|
strcpy(ScanCtx.index.desc.type, INDEX_TYPE_NDJSON);
|
||||||
|
|
||||||
unsigned char index_md5[MD5_DIGEST_LENGTH];
|
if (args->incremental != NULL) {
|
||||||
MD5((unsigned char *) &ScanCtx.index.desc.timestamp, sizeof(ScanCtx.index.desc.timestamp), index_md5);
|
// copy old index id
|
||||||
buf2hex(index_md5, MD5_DIGEST_LENGTH, ScanCtx.index.desc.id);
|
char descriptor_path[PATH_MAX];
|
||||||
|
snprintf(descriptor_path, PATH_MAX, "%sdescriptor.json", args->incremental);
|
||||||
|
index_descriptor_t original_desc = read_index_descriptor(descriptor_path);
|
||||||
|
memcpy(ScanCtx.index.desc.id, original_desc.id, sizeof(original_desc.id));
|
||||||
|
} else {
|
||||||
|
// genreate new index id based on timestamp
|
||||||
|
unsigned char index_md5[MD5_DIGEST_LENGTH];
|
||||||
|
MD5((unsigned char *) &ScanCtx.index.desc.timestamp, sizeof(ScanCtx.index.desc.timestamp), index_md5);
|
||||||
|
buf2hex(index_md5, MD5_DIGEST_LENGTH, ScanCtx.index.desc.id);
|
||||||
|
}
|
||||||
|
|
||||||
write_index_descriptor(path, &ScanCtx.index.desc);
|
write_index_descriptor(path, &ScanCtx.index.desc);
|
||||||
}
|
}
|
||||||
@ -378,7 +387,7 @@ void sist2_scan(scan_args_t *args) {
|
|||||||
|
|
||||||
initialize_scan_context(args);
|
initialize_scan_context(args);
|
||||||
|
|
||||||
init_dir(ScanCtx.index.path);
|
init_dir(ScanCtx.index.path, args);
|
||||||
|
|
||||||
char store_path[PATH_MAX];
|
char store_path[PATH_MAX];
|
||||||
snprintf(store_path, PATH_MAX, "%sthumbs", ScanCtx.index.path);
|
snprintf(store_path, PATH_MAX, "%sthumbs", ScanCtx.index.path);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user