All pastes #812559 Raw Edit

zypp refresh

public cpp v1 · immutable
#812559 ·published 2007-12-11 21:34 UTC
rendered paste body
static gbooleanbackend_refresh_cache_thread (PkBackend *backend, gpointer data){	RefreshData *d = (RefreshData*) data;	gboolean force = d->force;	g_free (d);	pk_backend_change_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);	pk_backend_change_percentage (backend, 0);	zypp::RepoManager manager;	std::list <zypp::RepoInfo> repos;	try	{		repos = manager.knownRepositories();	}	catch ( const zypp::Exception &e)	{		// FIXME: make sure this dumps out the right sring.		pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, e.asUserString().c_str() );		pk_backend_finished (backend);		return FALSE;	}	int i = 1;	int num_of_repos = repos.size ();	int percentage_increment = 100 / num_of_repos;	for (std::list <zypp::RepoInfo>::iterator it = repos.begin(); it != repos.end(); it++, i++) {		zypp::RepoInfo repo (*it);		// skip disabled repos		if (repo.enabled () == false)			continue;		// skip changeable meda (DVDs and CDs).  Without doing this,		// the disc would be required to be physically present.		if (zypp_is_changeable_media (*repo.baseUrlsBegin ()) == true)			continue;		try {fprintf (stderr, "\n\n *** Refreshing metadata ***\n\n");			manager.refreshMetadata (repo, force == TRUE ?				zypp::RepoManager::RefreshForced :				zypp::RepoManager::RefreshIfNeeded);		} catch (const zypp::Exception &ex) {			pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString ().c_str ());			pk_backend_finished (backend);			return FALSE;		}		try {fprintf (stderr, "\n\n *** Building cache ***\n\n");			manager.buildCache (repo, force == TRUE ?				zypp::RepoManager::BuildForced :				zypp::RepoManager::BuildIfNeeded);		//} catch (const zypp::repo::RepoNoUrlException &ex) {		//} catch (const zypp::repo::RepoNoAliasException &ex) {		//} catch (const zypp::repo::RepoUnknownTypeException &ex) {		//} catch (const zypp::repo::RepoException &ex) {		} catch (const zypp::Exception &ex) {			// TODO: Handle the exceptions in manager.refreshMetadata			pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString().c_str() );			pk_backend_finished (backend);			return FALSE;		}		// Update the percentage completed		pk_backend_change_percentage (backend,					      i == num_of_repos ?						100 :						i * percentage_increment);	}	pk_backend_finished (backend);	return TRUE;}