fix: add missing error checking for sync command
This commit is contained in:
@ -26,6 +26,16 @@ bool __lm_ctx_sync_callback(char *path, size_t current, size_t total, void *data
|
||||
}
|
||||
|
||||
size_t lm_ctx_sync(lm_ctx_t *ctx, bool do_update, lm_ctx_sync_callback_t callback, void *data){
|
||||
if(NULL == ctx) {
|
||||
lm_error_set(LM_ERR_ArgNULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(NULL == ctx->pools){
|
||||
lm_error_set(LM_ERR_NoPools);
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct __lm_ctx_sync_cb_data cbdata = {
|
||||
.ctx = ctx,
|
||||
.callback = callback,
|
||||
@ -41,6 +51,7 @@ size_t lm_ctx_sync(lm_ctx_t *ctx, bool do_update, lm_ctx_sync_callback_t callbac
|
||||
|
||||
if(lm_pool_path_is_empty(cur)){
|
||||
pdebug(__func__, "(%s) failed to load info, pool paths are empty", cur->name);
|
||||
lm_error_set(LM_ERR_PoolPathsEmpty);
|
||||
goto next_info;
|
||||
}
|
||||
|
||||
|
@ -156,6 +156,7 @@ void lm_error_set(lm_error_t code, ...) {
|
||||
{.code = LM_ERR_FileHashFail, .desc = _("failed to get hash of %s: %s") },
|
||||
{.code = LM_ERR_FileHashNoMatch, .desc = _("file hash does not match for %s") },
|
||||
{.code = LM_ERR_InfoNotLoaded, .desc = _("pool info is not loaded") },
|
||||
{.code = LM_ERR_NoPools, .desc = _("pool list is empty") },
|
||||
};
|
||||
|
||||
char *fmt = NULL;
|
||||
|
Reference in New Issue
Block a user