FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 02-18-2008, 10:56 AM
Xavier
 
Default Move -Sy operation into its own transaction

On Mon, Feb 18, 2008 at 12:15:37AM -0600, Dan McGee wrote:
> > diff --git a/src/pacman/sync.c b/src/pacman/sync.c
> > index 27218d6..bb2a8bb 100644
> > --- a/src/pacman/sync.c
> > +++ b/src/pacman/sync.c
> > @@ -202,6 +202,17 @@ static int sync_synctree(int level, alpm_list_t *syncs)
> > alpm_list_t *i;
> > int success = 0, ret;
> >
> > + if(alpm_trans_init(PM_TRANS_TYPE_SYNC, 0, cb_trans_evt,
> > + cb_trans_conv, cb_trans_progress) == -1) {
> > + fprintf(stderr, _("error: failed to init transaction (%s)
"),
> > + alpm_strerrorlast());
> > + if(pm_errno == PM_ERR_HANDLE_LOCK) {
> > + printf(_(" if you're sure a package manager is not already
"
> > + " running, you can remove %s.
"), alpm_option_get_lockfile());
> > + }
> > + return(0);
> > + }
> > +
>
> Don't we have this same code in a few different places now? Can we
> refactor this somehow?
>

I will see what I can do.

> > for(i = syncs; i; i = alpm_list_next(i)) {
> > pmdb_t *db = alpm_list_getdata(i);
> >
> > @@ -229,10 +240,18 @@ static int sync_synctree(int level, alpm_list_t *syncs)
> > }
> > }
> >
> > + if(alpm_trans_release() == -1) {
> > + fprintf(stderr, _("error: failed to release transaction (%s)
"),
> > + alpm_strerrorlast());
> > + return(0);
> > + }
> > /* We should always succeed if at least one DB was upgraded - we may possibly
> > * fail later with unresolved deps, but that should be rare, and would be
> > * expected
> > */
> What is this comment even referring to? I'm confused here. And you had
> code changes on either side of it.
>
> > + if(!success) {
> > + fprintf(stderr, _("error: failed to synchronize any databases
"));
> > + }
> > return(success > 0);
> > }
> >


Well, it simply refers to that last part.
If at least one DB was upgraded (success > 0), we return 1.
Otherwise (success = 0), we print an error and return 0.

_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 

Thread Tools




All times are GMT. The time now is 07:41 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org