Skip to content

Commit

Permalink
clean up and warn if cacxhe dir is not empty but should be
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverkurth committed Jul 5, 2022
1 parent 2596873 commit 6c3fe2a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 37 deletions.
14 changes: 14 additions & 0 deletions client/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,20 @@ TDNFClean(

/* remove the top level repo cache dir if it's not empty */
dwError = TDNFRepoRemoveCacheDir(pTdnf, pRepo);
if (dwError == ERROR_TDNF_SYSTEM_BASE + ENOTEMPTY)
{
/* if we did a 'clean all' the directory should be empty now. If
not we either missed something or someone other than us
put a file there, so warn about it, but don't bail out.
If we did clean just one part it's not expected to be empty
unless the other parts were already cleaned.
*/
if (nCleanType == CLEANTYPE_ALL)
{
pr_err("Cache directory for %s not removed because it's not empty.\n", pRepo->pszId);
}
dwError = 0;
}
BAIL_ON_TDNF_ERROR(dwError);

pr_info("\n");
Expand Down
58 changes: 27 additions & 31 deletions client/repolist.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,42 +645,38 @@ TDNFRepoListFinalize(
}

/* Now that the overrides are applied, replace config vars
for the repos that are enabled. */
for all repos. */
for(pRepo = pTdnf->pRepos; pRepo; pRepo = pRepo->pNext)
{
// if(pRepo->nEnabled)
if (1)
if(pRepo->pszName)
{
if(pRepo->pszName)
{
dwError = TDNFConfigReplaceVars(pTdnf, &pRepo->pszName);
BAIL_ON_TDNF_ERROR(dwError);
}
if(pRepo->pszBaseUrl)
{
dwError = TDNFConfigReplaceVars(pTdnf, &pRepo->pszBaseUrl);
BAIL_ON_TDNF_ERROR(dwError);
}
if(pRepo->pszMetaLink)
{
dwError = TDNFConfigReplaceVars(pTdnf, &pRepo->pszMetaLink);
BAIL_ON_TDNF_ERROR(dwError);
}

if (pRepo->pszMetaLink)
{
dwError = SolvCreateRepoCacheName(pRepo->pszId,
pRepo->pszMetaLink,
&pRepo->pszCacheName);
}
else if (pRepo->pszBaseUrl)
{
dwError = SolvCreateRepoCacheName(pRepo->pszId,
pRepo->pszBaseUrl,
&pRepo->pszCacheName);
}
dwError = TDNFConfigReplaceVars(pTdnf, &pRepo->pszName);
BAIL_ON_TDNF_ERROR(dwError);
}
if(pRepo->pszBaseUrl)
{
dwError = TDNFConfigReplaceVars(pTdnf, &pRepo->pszBaseUrl);
BAIL_ON_TDNF_ERROR(dwError);
}
if(pRepo->pszMetaLink)
{
dwError = TDNFConfigReplaceVars(pTdnf, &pRepo->pszMetaLink);
BAIL_ON_TDNF_ERROR(dwError);
}

if (pRepo->pszMetaLink)
{
dwError = SolvCreateRepoCacheName(pRepo->pszId,
pRepo->pszMetaLink,
&pRepo->pszCacheName);
}
else if (pRepo->pszBaseUrl)
{
dwError = SolvCreateRepoCacheName(pRepo->pszId,
pRepo->pszBaseUrl,
&pRepo->pszCacheName);
}
BAIL_ON_TDNF_ERROR(dwError);
}
cleanup:
return dwError;
Expand Down
9 changes: 3 additions & 6 deletions client/repoutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,10 @@ TDNFRepoRemoveCacheDir(
&pszRepoCacheDir);
BAIL_ON_TDNF_ERROR(dwError);

if (rmdir(pszRepoCacheDir) != 0)
if (rmdir(pszRepoCacheDir) != 0 && errno != ENOENT)
{
/* ignore ENOTEMPTY, let's keep the dir if it's not empty */
if (errno != ENOENT && errno != ENOTEMPTY)
{
BAIL_ON_TDNF_ERROR(errno);
}
dwError = errno;
BAIL_ON_TDNF_SYSTEM_ERROR(dwError);
}

cleanup:
Expand Down

0 comments on commit 6c3fe2a

Please sign in to comment.