fix: remove operation file check fixes
This commit is contained in:
parent
216ca5c9dd
commit
d0dce209fa
@ -44,6 +44,8 @@ int main(int argc, char *argv[]) {
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("removing package: %s (%s)...\n", pkg.name, pkg.version);
|
||||||
|
|
||||||
if (!lm_ctx_remove(&ctx, &pkg, NULL, NULL)) {
|
if (!lm_ctx_remove(&ctx, &pkg, NULL, NULL)) {
|
||||||
printf("failed to remove package: %s (%d)\n", lm_strerror(), lm_error());
|
printf("failed to remove package: %s (%d)\n", lm_strerror(), lm_error());
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -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-08 12:47+0300\n"
|
"POT-Creation-Date: 2024-07-08 13:05+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"
|
||||||
|
@ -15,6 +15,14 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
bool __lm_ctx_run_install(char *root, char *install_path) {
|
bool __lm_ctx_run_install(char *root, char *install_path) {
|
||||||
|
struct stat st;
|
||||||
|
bzero(&st, sizeof(st));
|
||||||
|
stat(install_path, &st);
|
||||||
|
|
||||||
|
// no need to run empty install script :)
|
||||||
|
if(st.st_size <= 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
char *args[] = {"/bin/bash", install_path, NULL}, *oldpwd = NULL;
|
char *args[] = {"/bin/bash", install_path, NULL}, *oldpwd = NULL;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
@ -14,6 +14,11 @@ bool lm_ctx_remove(lm_ctx_t *ctx, lm_pkg_t *pkg, lm_ctx_remove_callback_t callba
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(NULL == ctx->root){
|
||||||
|
lm_error_set(LM_ERR_CtxRootNULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(!lm_ctx_database_is_installed(ctx, pkg, true)){
|
if(!lm_ctx_database_is_installed(ctx, pkg, true)){
|
||||||
lm_error_set(LM_ERR_PkgNotInstalled);
|
lm_error_set(LM_ERR_PkgNotInstalled);
|
||||||
return false;
|
return false;
|
||||||
@ -22,8 +27,8 @@ bool lm_ctx_remove(lm_ctx_t *ctx, lm_pkg_t *pkg, lm_ctx_remove_callback_t callba
|
|||||||
if(!lm_ctx_database_init(ctx))
|
if(!lm_ctx_database_init(ctx))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
char *path = NULL, *hash = NULL, *fpath = NULL;
|
||||||
size_t total = 0, current = 0;
|
size_t total = 0, current = 0;
|
||||||
char *path = NULL, *hash = NULL;
|
|
||||||
bool in_keep = false, ret = false;
|
bool in_keep = false, ret = false;
|
||||||
|
|
||||||
total = lm_database_files_count(ctx->db, pkg);
|
total = lm_database_files_count(ctx->db, pkg);
|
||||||
@ -32,13 +37,25 @@ bool lm_ctx_remove(lm_ctx_t *ctx, lm_pkg_t *pkg, lm_ctx_remove_callback_t callba
|
|||||||
if(in_keep)
|
if(in_keep)
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
if(exists(path) && unlink(path) < 0){
|
fpath = join_alloc(ctx->root, path);
|
||||||
pdebug(__func__, "failed to delete file for removing %s: %s", pkg->name, errno);
|
pdebug(__func__, "removing file %s (%s)", fpath, pkg->name);
|
||||||
lm_error_set(LM_ERR_PkgFileUnlinkFail, path, strerror(errno));
|
|
||||||
goto end;
|
if(!exists(fpath)){
|
||||||
|
pdebug(__func__, "found file in database, but its not on the file system: %s", fpath);
|
||||||
|
goto next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(unlink(fpath) < 0){
|
||||||
|
pdebug(__func__, "failed to delete file for removing %s: %s", pkg->name, strerror(errno));
|
||||||
|
lm_error_set(LM_ERR_PkgFileUnlinkFail, path, strerror(errno));
|
||||||
|
goto next;
|
||||||
|
}
|
||||||
|
|
||||||
next:
|
next:
|
||||||
if(!callback(ctx, pkg, path, ++current, total, data))
|
free(fpath);
|
||||||
|
fpath = NULL;
|
||||||
|
|
||||||
|
if(NULL != callback && !callback(ctx, pkg, fpath, ++current, total, data))
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ size_t lm_database_files_count(lm_database_t *db, lm_pkg_t *pkg){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite3_bind_text(db->files_st, FILES_COLUMN_PACKAGE, pkg->name, strlen(pkg->name), SQLITE_STATIC);
|
sqlite3_bind_text(db->files_st, 1, pkg->name, strlen(pkg->name), SQLITE_STATIC);
|
||||||
|
|
||||||
while(sqlite3_step(db->files_st) == SQLITE_ROW)
|
while(sqlite3_step(db->files_st) == SQLITE_ROW)
|
||||||
count++;
|
count++;
|
||||||
@ -85,7 +85,7 @@ bool lm_database_files_matches(lm_database_t *db, char *path, char *hash){
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite3_bind_text(db->files_st, FILES_COLUMN_PATH, path, strlen(path), SQLITE_STATIC);
|
sqlite3_bind_text(db->files_st, 1, path, strlen(path), SQLITE_STATIC);
|
||||||
|
|
||||||
if(sqlite3_step(db->files_st) != SQLITE_ROW){
|
if(sqlite3_step(db->files_st) != SQLITE_ROW){
|
||||||
pdebug(__func__, "failed to execute select statement for selecting %s: %s", path, sqlite3_errmsg(db->files_db));
|
pdebug(__func__, "failed to execute select statement for selecting %s: %s", path, sqlite3_errmsg(db->files_db));
|
||||||
@ -119,7 +119,7 @@ bool lm_database_files_iskeep(lm_database_t *db, char *path){
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite3_bind_text(db->files_st, FILES_COLUMN_PATH, path, strlen(path), SQLITE_STATIC);
|
sqlite3_bind_text(db->files_st, 1, path, strlen(path), SQLITE_STATIC);
|
||||||
|
|
||||||
if(!lm_database_step_all(db->files_st)){
|
if(!lm_database_step_all(db->files_st)){
|
||||||
pdebug(__func__, "failed to execute select statement for selecting %s: %s", path, sqlite3_errmsg(db->files_db));
|
pdebug(__func__, "failed to execute select statement for selecting %s: %s", path, sqlite3_errmsg(db->files_db));
|
||||||
@ -190,7 +190,7 @@ bool lm_database_files_del(lm_database_t *db, lm_pkg_t *pkg){
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite3_bind_text(db->files_st, FILES_COLUMN_PACKAGE, pkg->name, strlen(pkg->name), SQLITE_STATIC);
|
sqlite3_bind_text(db->files_st, 1, pkg->name, strlen(pkg->name), SQLITE_STATIC);
|
||||||
|
|
||||||
if(!lm_database_step_all(db->files_st)){
|
if(!lm_database_step_all(db->files_st)){
|
||||||
pdebug(__func__, "failed to execute delete statement for deleting %s: %s", pkg->name, sqlite3_errmsg(db->files_db));
|
pdebug(__func__, "failed to execute delete statement for deleting %s: %s", pkg->name, sqlite3_errmsg(db->files_db));
|
||||||
@ -219,7 +219,7 @@ bool lm_database_files_next(lm_database_t *db, lm_pkg_t *pkg, char **path, char
|
|||||||
lm_error_set(LM_ERR_DbSqlPrepareFail);
|
lm_error_set(LM_ERR_DbSqlPrepareFail);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
sqlite3_bind_text(db->files_st, FILES_COLUMN_PACKAGE, pkg->name, strlen(pkg->name), SQLITE_STATIC);
|
sqlite3_bind_text(db->files_st, 1, pkg->name, strlen(pkg->name), SQLITE_STATIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(NULL != db->files_st){
|
else if(NULL != db->files_st){
|
||||||
|
Loading…
Reference in New Issue
Block a user