update: refactoring and small fixes

This commit is contained in:
ngn
2024-07-31 21:16:19 +03:00
parent 3f794e1a90
commit 9cd4eb9905
41 changed files with 779 additions and 752 deletions

View File

@ -6,8 +6,8 @@
#include <stdio.h>
#include <string.h>
bool lm_ctx_check(lm_ctx_t *ctx, lm_pkg_t *pkg, lm_ctx_check_callback_t callback, void *data){
if(NULL == ctx || NULL == pkg){
bool lm_ctx_check(lm_ctx_t *ctx, lm_entry_t *entry, lm_ctx_check_callback_t callback, void *data){
if(NULL == ctx || NULL == entry){
lm_error_set(LM_ERR_ArgNULL);
return false;
}
@ -24,9 +24,9 @@ bool lm_ctx_check(lm_ctx_t *ctx, lm_pkg_t *pkg, lm_ctx_check_callback_t callback
char *path = NULL, *hash = NULL, *fhash = NULL;
bool keep = false, ret = false;
total = lm_database_files_count(ctx->db, pkg);
total = lm_database_files_count(ctx->db, entry);
while(lm_database_files_next(ctx->db, pkg, &path, &hash, &keep)){
while(lm_database_files_next(ctx->db, entry, &path, &hash, &keep)){
char fp[rootlen+strlen(path)+10];
join(fp, ctx->root, path);
current++;
@ -34,7 +34,7 @@ bool lm_ctx_check(lm_ctx_t *ctx, lm_pkg_t *pkg, lm_ctx_check_callback_t callback
pdebug(__func__, "(%d/%d) checking %s", current, total, fp);
if(NULL != callback)
if(!callback(ctx, pkg, fp, current, total, data))
if(!callback(ctx, entry, fp, current, total, data))
goto end;
if(!exists(fp)){
@ -61,7 +61,7 @@ bool lm_ctx_check(lm_ctx_t *ctx, lm_pkg_t *pkg, lm_ctx_check_callback_t callback
ret = true;
end:
lm_database_files_next_free(ctx->db, pkg, &path, &hash, &keep);
lm_database_files_next_free(ctx->db, entry, &path, &hash, &keep);
free(fhash);
return ret;
}