new: add callback for serve command
This commit is contained in:
@ -8,17 +8,12 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
bool lm_ctx_remove(lm_ctx_t *ctx, lm_pkg_t *pkg, lm_ctx_remove_callback_t callback, void *data){
|
||||
bool lm_ctx_removeable(lm_ctx_t *ctx, lm_pkg_t *pkg){
|
||||
if(NULL == ctx && NULL == pkg){
|
||||
lm_error_set(LM_ERR_ArgNULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(NULL == ctx->root){
|
||||
lm_error_set(LM_ERR_CtxRootNULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!lm_ctx_database_is_installed(ctx, pkg, true)){
|
||||
lm_error_set(LM_ERR_PkgNotInstalled);
|
||||
return false;
|
||||
@ -37,6 +32,24 @@ bool lm_ctx_remove(lm_ctx_t *ctx, lm_pkg_t *pkg, lm_ctx_remove_callback_t callba
|
||||
}
|
||||
}
|
||||
|
||||
lm_database_package_next_free(ctx->db, &cur);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool lm_ctx_remove(lm_ctx_t *ctx, lm_pkg_t *pkg, lm_ctx_remove_callback_t callback, void *data){
|
||||
if(NULL == ctx && NULL == pkg){
|
||||
lm_error_set(LM_ERR_ArgNULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(NULL == ctx->root){
|
||||
lm_error_set(LM_ERR_CtxRootNULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!lm_ctx_database_init(ctx))
|
||||
return false;
|
||||
|
||||
char *path = NULL, *hash = NULL, *fpath = NULL;
|
||||
bool in_keep = false, ret = false;
|
||||
size_t total = 0, current = 0;
|
||||
@ -94,7 +107,6 @@ bool lm_ctx_remove(lm_ctx_t *ctx, lm_pkg_t *pkg, lm_ctx_remove_callback_t callba
|
||||
|
||||
ret = true;
|
||||
end:
|
||||
lm_database_package_next_free(ctx->db, &cur);
|
||||
lm_database_files_next_free(ctx->db, pkg, &path, &hash, &in_keep);
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user