Skip to content

Commit

Permalink
Merge pull request #21 from ppadmavilasom/master
Browse files Browse the repository at this point in the history
fix makecache issues. engage refresh flag
  • Loading branch information
ppadmavilasom committed Sep 8, 2015
2 parents 454b134 + a66e9fd commit 245eae4
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 138 deletions.
1 change: 0 additions & 1 deletion client/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ libtdnfclient_la_SOURCES = \
goal.c \
gpgcheck.c \
init.c \
makecache.c \
memory.c \
packageutils.c \
repo.c \
Expand Down
48 changes: 3 additions & 45 deletions client/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,25 +459,18 @@ TDNFMakeCache(
)
{
uint32_t dwError = 0;
PTDNF_CLEAN_INFO pCleanInfo = NULL;

if(!pTdnf)
{
dwError = ERROR_TDNF_INVALID_PARAMETER;
BAIL_ON_TDNF_ERROR(dwError);
}
//Do clean metadata and refresh
dwError = TDNFClean(pTdnf, CLEANTYPE_ALL, &pCleanInfo);
BAIL_ON_TDNF_ERROR(dwError);

dwError = TDNFRefreshCache(pTdnf);
//Pass in clean metadata as 1
dwError = TDNFRefreshSack(pTdnf, 1);
BAIL_ON_TDNF_ERROR(dwError);

cleanup:
if(pCleanInfo)
{
TDNFFreeCleanInfo(pCleanInfo);
}
return dwError;

error:
Expand All @@ -494,8 +487,6 @@ TDNFOpenHandle(
{
uint32_t dwError = 0;
PTDNF pTdnf = NULL;
HyRepo hRepo = NULL;
int nYumFlags = HY_LOAD_FILELISTS | HY_LOAD_UPDATEINFO;

if(!pArgs || !ppTdnf)
{
Expand All @@ -520,42 +511,9 @@ TDNFOpenHandle(
&pTdnf->pRepos);
BAIL_ON_TDNF_ERROR(dwError);

dwError = TDNFInitSack(pTdnf, &pTdnf->hSack, HY_LOAD_FILELISTS);
dwError = TDNFRefreshSack(pTdnf, pTdnf->pArgs->nRefresh);
BAIL_ON_TDNF_ERROR(dwError);

//If there is an empty repo directory, do nothing
if(pTdnf->pRepos)
{
PTDNF_REPO_DATA pTempRepo = pTdnf->pRepos;
while(pTempRepo)
{
if(pTempRepo->nEnabled)
{
dwError = TDNFInitRepo(pTdnf, pTempRepo, &hRepo);
if(dwError)
{
if(pTempRepo->nSkipIfUnavailable)
{
pTempRepo->nEnabled = 0;
fprintf(stderr, "Disabling Repo: '%s'\n", pTempRepo->pszName);

dwError = 0;
}
}
BAIL_ON_TDNF_ERROR(dwError);

if(pTempRepo->nEnabled)
{
pTempRepo->hRepo = hRepo;

dwError = TDNFLoadYumRepo(pTdnf->hSack, hRepo, nYumFlags);
BAIL_ON_TDNF_ERROR(dwError);
}
}
pTempRepo = pTempRepo->pNext;
}
}

*ppTdnf = pTdnf;

cleanup:
Expand Down
4 changes: 2 additions & 2 deletions client/goal.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,11 @@ TDNFGoalReportProblems(
nCount = hy_goal_count_problems(hGoal);
if(nCount > 0)
{
fprintf(stderr, "Found %d problem(s) while resolving\n", nCount);
fprintf(stdout, "Found %d problem(s) while resolving\n", nCount);
for(; i < nCount; ++i)
{
pszProblem = hy_goal_describe_problem(hGoal, i);
fprintf(stderr, "%d. %s\n", i+1, pszProblem);
fprintf(stdout, "%d. %s\n", i+1, pszProblem);

hy_free(pszProblem);
pszProblem = NULL;
Expand Down
82 changes: 82 additions & 0 deletions client/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,85 @@ TDNFCloneCmdArgs(
goto cleanup;
}

uint32_t
TDNFRefreshSack(
PTDNF pTdnf,
int nCleanMetadata
)
{
uint32_t dwError = 0;
HyRepo hRepo = NULL;
int nYumFlags = HY_LOAD_FILELISTS | HY_LOAD_UPDATEINFO;

if(!pTdnf)
{
dwError = ERROR_TDNF_INVALID_PARAMETER;
BAIL_ON_TDNF_ERROR(dwError);
}

if(pTdnf->hSack)
{
hy_sack_free(pTdnf->hSack);
pTdnf->hSack = NULL;
}

dwError = TDNFInitSack(pTdnf, &pTdnf->hSack, HY_LOAD_FILELISTS);
BAIL_ON_TDNF_ERROR(dwError);

//If there is an empty repo directory, do nothing
if(pTdnf->pRepos)
{
PTDNF_REPO_DATA pTempRepo = pTdnf->pRepos;
while(pTempRepo)
{
if(pTempRepo->nEnabled)
{
if(nCleanMetadata)
{
fprintf(stdout,
"Refreshing metadata for: '%s'\n",
pTempRepo->pszName);
dwError = TDNFRepoRemoveCache(pTdnf, pTempRepo->pszId);
if(dwError == ERROR_TDNF_FILE_NOT_FOUND)
{
dwError = 0;//Ignore non existent folders
}
BAIL_ON_TDNF_ERROR(dwError);
}

dwError = TDNFInitRepo(pTdnf, pTempRepo, &hRepo);
if(dwError)
{
if(pTempRepo->nSkipIfUnavailable)
{
pTempRepo->nEnabled = 0;
fprintf(stdout, "Disabling Repo: '%s'\n", pTempRepo->pszName);

dwError = 0;
}
}
BAIL_ON_TDNF_ERROR(dwError);

if(pTempRepo->nEnabled)
{
if(pTempRepo->hRepo)
{
hy_repo_free(pTempRepo->hRepo);
pTempRepo->hRepo = NULL;
}
pTempRepo->hRepo = hRepo;

dwError = TDNFLoadYumRepo(pTdnf->hSack, hRepo, nYumFlags);
BAIL_ON_TDNF_ERROR(dwError);
}
}
pTempRepo = pTempRepo->pNext;
}
}

cleanup:
return dwError;

error:
goto cleanup;
}
85 changes: 0 additions & 85 deletions client/makecache.c

This file was deleted.

6 changes: 6 additions & 0 deletions client/prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ TDNFLoadYumRepo(
int nFlags
);

uint32_t
TDNFRefreshSack(
PTDNF pTdnf,
int nCleanMetadata
);

//makecache.c
uint32_t
TDNFRefreshCache(
Expand Down
9 changes: 7 additions & 2 deletions client/repo.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,13 @@ TDNFGetGPGCheck(
if(pRepo)
{
nGPGCheck = pRepo->nGPGCheck;
dwError = TDNFAllocateString(pRepo->pszUrlGPGKey, &pszUrlGPGKey);
BAIL_ON_TDNF_ERROR(dwError);
if(nGPGCheck)
{
dwError = TDNFAllocateString(
pRepo->pszUrlGPGKey,
&pszUrlGPGKey);
BAIL_ON_TDNF_ERROR(dwError);
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions client/repoutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ TDNFRepoRemoveCache(
dwError = errno;
BAIL_ON_TDNF_SYSTEM_ERROR(dwError);
}
if(pszFilePath)
{
g_free(pszFilePath);
pszFilePath = NULL;
}
}
if(rmdir(pszRepoCacheDir))
{
Expand All @@ -255,6 +260,10 @@ TDNFRepoRemoveCache(
{
g_free(pszRepoCacheDir);
}
if(pDir)
{
g_dir_close(pDir);
}
return dwError;

error:
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AC_INIT(tdnf, 1.0.2)
AC_INIT(tdnf, 1.0.3)
AC_MSG_NOTICE([tdnf configuration])

AC_CANONICAL_SYSTEM
Expand Down
9 changes: 7 additions & 2 deletions tools/cli/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ int main(int argc, char* argv[])
{
nFound = 1;

if(!strcmp(pszCmd, "makecache"))
{
pCmdArgs->nRefresh = 1;
}

dwError = TDNFOpenHandle(pCmdArgs, &pTdnf);
BAIL_ON_CLI_ERROR(dwError);

Expand Down Expand Up @@ -515,8 +520,8 @@ TDNFCliMakeCacheCommand(
dwError = ERROR_TDNF_CLI_INVALID_ARGUMENT;
BAIL_ON_CLI_ERROR(dwError);
}
dwError = TDNFMakeCache(pTdnf);
BAIL_ON_CLI_ERROR(dwError);
//Empty as refresh flag is set for makecache command
//and will execute refresh on all enabled repos

fprintf(stdout, "Metadata cache created.\n");

Expand Down

0 comments on commit 245eae4

Please sign in to comment.