fix: add missing error checking for sync command
This commit is contained in:
parent
16cfc0676e
commit
d66fefa1d4
@ -139,6 +139,7 @@ typedef enum lm_error {
|
|||||||
LM_ERR_FileHashFail = 131,
|
LM_ERR_FileHashFail = 131,
|
||||||
LM_ERR_FileHashNoMatch = 132,
|
LM_ERR_FileHashNoMatch = 132,
|
||||||
LM_ERR_InfoNotLoaded = 133,
|
LM_ERR_InfoNotLoaded = 133,
|
||||||
|
LM_ERR_NoPools = 134,
|
||||||
} lm_error_t;
|
} lm_error_t;
|
||||||
|
|
||||||
typedef struct lm_error_desc {
|
typedef struct lm_error_desc {
|
||||||
|
@ -8,7 +8,7 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2024-07-14 21:05+0300\n"
|
"POT-Creation-Date: 2024-07-16 16:03+0300\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@ -587,3 +587,7 @@ msgstr ""
|
|||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid "pool info is not loaded"
|
msgid "pool info is not loaded"
|
||||||
msgstr "URL hostname is too large"
|
msgstr "URL hostname is too large"
|
||||||
|
|
||||||
|
#: src/error.c:159
|
||||||
|
msgid "pool list is empty"
|
||||||
|
msgstr ""
|
||||||
|
@ -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){
|
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 = {
|
struct __lm_ctx_sync_cb_data cbdata = {
|
||||||
.ctx = ctx,
|
.ctx = ctx,
|
||||||
.callback = callback,
|
.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)){
|
if(lm_pool_path_is_empty(cur)){
|
||||||
pdebug(__func__, "(%s) failed to load info, pool paths are empty", cur->name);
|
pdebug(__func__, "(%s) failed to load info, pool paths are empty", cur->name);
|
||||||
|
lm_error_set(LM_ERR_PoolPathsEmpty);
|
||||||
goto next_info;
|
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_FileHashFail, .desc = _("failed to get hash of %s: %s") },
|
||||||
{.code = LM_ERR_FileHashNoMatch, .desc = _("file hash does not match for %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_InfoNotLoaded, .desc = _("pool info is not loaded") },
|
||||||
|
{.code = LM_ERR_NoPools, .desc = _("pool list is empty") },
|
||||||
};
|
};
|
||||||
|
|
||||||
char *fmt = NULL;
|
char *fmt = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user