fix: add some missing error checking with install operation

This commit is contained in:
ngn 2024-07-16 19:33:18 +03:00
parent d66fefa1d4
commit afa81c7284
3 changed files with 12 additions and 6 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-07-16 16:03+0300\n"
"POT-Creation-Date: 2024-07-16 19:29+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -170,11 +170,6 @@ bool lm_ctx_install(lm_ctx_t *ctx, lm_pkg_t *pkg, lm_ctx_install_callback_t call
return false;
}
if(lm_ctx_database_is_installed(ctx, pkg, false)){
lm_error_set(LM_ERR_PkgAlreadyInstalled);
return false;
}
if(NULL == ctx->root){
lm_error_set(LM_ERR_CtxRootNULL);
return false;
@ -188,6 +183,16 @@ bool lm_ctx_install(lm_ctx_t *ctx, lm_pkg_t *pkg, lm_ctx_install_callback_t call
if(!lm_ctx_database_init(ctx))
return false; // error set by function
if(lm_ctx_database_is_installed(ctx, pkg, false)){
lm_error_set(LM_ERR_PkgAlreadyInstalled);
return false;
}
if(lm_package_path_is_empty(pkg)){
lm_error_set(LM_ERR_PkgPathsEmpty);
return false;
}
if(!extract_archive(ctx->temp, pkg->paths.archive))
return false; // error set by function

View File

@ -140,6 +140,7 @@ bool extract_archive(char *dst, char *src) {
char srcfull[PATH_MAX + 1];
if (NULL == realpath(src, srcfull)) {
pdebug(__func__, "failed to get realpath for %s: %s", src, strerror(errno));
lm_error_set(LM_ERR_ArcRealpathFail);
goto end;
}