示例#1
0
文件: makecache.c 项目: hguemar/tdnf
uint32_t
TDNFRefreshCache(
    PTDNF pTdnf
    )
{
    uint32_t dwError = 0;
    HySack hSack = NULL;

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

    //Creating a new sack without removing the
    //old one did not work well. Remove first, then 
    //create 
    if(pTdnf->hSack)
    {
        hy_sack_free(pTdnf->hSack);
        pTdnf->hSack = NULL;
    }

    //init with cache
    dwError = TDNFInitSack(pTdnf, &hSack, HY_LOAD_FILELISTS);
    BAIL_ON_TDNF_ERROR(dwError);

    //Do the same for all enabled repos
    if(pTdnf->pRepos)
    {
        PTDNF_REPO_DATA pRepo = pTdnf->pRepos;
        while(pRepo)
        {
            if(pRepo->nEnabled)
            {
                hy_repo_free(pRepo->hRepo);
                pRepo->hRepo = NULL;

                dwError = TDNFInitRepo(pTdnf, pRepo, &pRepo->hRepo);
                BAIL_ON_TDNF_ERROR(dwError);
            }
            pRepo = pRepo->pNext;
        }
    }

    pTdnf->hSack = hSack;

cleanup:
    return dwError;

error:
    if(hSack)
    {
        hy_sack_free(hSack);
    }
    if(pTdnf->hSack)
    {
        hy_sack_free(pTdnf->hSack);
        pTdnf->hSack = NULL;
    }
    goto cleanup;
}
示例#2
0
文件: init.c 项目: samwyse/tdnf
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;
}