[pacman-dev] [PATCH 8/9] Allow invalid sync DBs to be returned by the library
Dan McGee
dpmcgee at gmail.com
Wed Jun 8 08:18:03 EDT 2011
On Wed, Jun 8, 2011 at 6:38 AM, Allan McRae <allan at archlinux.org> wrote:
> On 08/06/11 17:51, Dan McGee wrote:
>> @@ -100,6 +103,28 @@ int needs_root(void)
>> }
>> }
>>
>> +int check_syncdbs(int min_count, int check_valid)
>> +{
>> + alpm_list_t *i, *sync_dbs;
>> + sync_dbs = alpm_option_get_syncdbs(config->handle);
>> + if(sync_dbs == NULL || alpm_list_count(sync_dbs)< min_count) {
>> + pm_printf(PM_LOG_ERROR, _("no usable package repositories
>> configured.\n"));
>> + return 1;
>> + }
>> + if(check_valid) {
>> + /* ensure all known dbs are valid */
>> + for(i = sync_dbs; i; i = alpm_list_next(i)) {
>> + pmdb_t *db = i->data;
>> + if(alpm_db_valid(db)) {
>> + pm_printf(PM_LOG_ERROR, _("database '%s'
>> is not valid (%s)\n"),
>> + alpm_db_get_name(db),
>> alpm_strerror(alpm_errno(config->handle)));
>> + return 1;
>
> Instead of returning immediately here, would it be good to finish checking
> all databases for validity?
I thought about that too when doing it and I was on the fence- I think
that is a good idea, as then you would know in one shot what all is
wrong. Just set error = 1 if we ever are invalid in the loop and then
return that value...
-Dan
More information about the pacman-dev
mailing list