fix: list archive extraction and package creation errors
This commit is contained in:
@ -29,11 +29,13 @@ bool lm_pool_list_load(lm_pool_t *pool, char *file){
|
||||
memcpy(file_copy2, file, file_len+1);
|
||||
|
||||
list_dir = dirname(file_copy);
|
||||
list_name = dirname(file_copy2);
|
||||
list_name = basename(file_copy2);
|
||||
|
||||
char extract_dir[file_len+15];
|
||||
snprintf(extract_dir, sizeof(extract_dir), "%s/%s_extracted", list_dir, list_name);
|
||||
|
||||
pdebug(__func__, "extracting pool to %s", extract_dir);
|
||||
|
||||
if(!mkdir_ifnot(extract_dir)){
|
||||
lm_error_set(LM_ERR_PoolListDirFail);
|
||||
return false;
|
||||
@ -53,24 +55,32 @@ bool lm_pool_list_load(lm_pool_t *pool, char *file){
|
||||
}
|
||||
|
||||
while((ent = readdir(dirfd)) != NULL){
|
||||
ent_len = strlen(ent->d_name);
|
||||
if(eq(ent->d_name, "..") || eq(ent->d_name, "."))
|
||||
continue;
|
||||
|
||||
ent_len = strlen(ent->d_name);
|
||||
char datap[ent_len+sizeof(extract_dir)+10];
|
||||
snprintf(datap, sizeof(datap), "%s/%s/DATA", extract_dir, ent->d_name);
|
||||
|
||||
|
||||
lm_pkg_t *pkg = lm_pkg_new();
|
||||
|
||||
if(!lm_pkg_data_load(pkg, datap)){
|
||||
pdebug(__func__, "(%s) failed to load new package from %s", pool->name, datap);
|
||||
lm_pkg_free(pkg);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!lm_pool_add(pool, pkg)){
|
||||
pdebug(__func__, "(%s) failed to add new package: %s", pool->name, pkg->name);
|
||||
lm_pkg_free(pkg);
|
||||
continue;
|
||||
}
|
||||
|
||||
pdebug(__func__, "(%s) added new package: %s", pool->name, pkg->name);
|
||||
}
|
||||
|
||||
ret = true;
|
||||
|
||||
end:
|
||||
if(NULL != dirfd)
|
||||
closedir(dirfd);
|
||||
|
Reference in New Issue
Block a user