Git-Url:
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2/.git;a=commitdiff;h=7b38029cf4c8fbcdb8361b50732c50bf97c79192
commit 7b38029cf4c8fbcdb8361b50732c50bf97c79192
Author: Christian Hamar alias krix <[EMAIL PROTECTED]>
Date: Tue Jul 24 19:00:48 2007 +0200
Small fixup (well another way to 'gain' remaining pkgs
* Not computing (computing bah .. remain++ ...) inside download.c
* Use idlearg3 and remain in server.c and compute remaining packs like we does
in add.c
diff --git a/lib/libftp/ftplib.c b/lib/libftp/ftplib.c
index db5e943..282037e 100644
--- a/lib/libftp/ftplib.c
+++ b/lib/libftp/ftplib.c
@@ -83,6 +83,7 @@ struct NetBuf {
FtpCallback idlecb;
void *idlearg;
void *idlearg2;
+ void *idlearg3;
int xfered;
int cbbytes;
int xfered1;
@@ -171,7 +172,7 @@ static int socket_wait(netbuf *ctl)
break;
}
}
- while ((rv = ctl->idlecb(ctl, ctl->xfered, ctl->idlearg,
ctl->idlearg2)));
+ while ((rv = ctl->idlecb(ctl, ctl->xfered, ctl->idlearg, ctl->idlearg2,
ctl->idlearg3)));
return rv;
}
@@ -476,6 +477,7 @@ GLOBALDEF int FtpConnect(const char *host, netbuf
**nControl)
ctrl->idletime.tv_sec = ctrl->idletime.tv_usec = 0;
ctrl->idlearg = NULL;
ctrl->idlearg2 = NULL;
+ ctrl->idlearg3 = NULL;
ctrl->xfered = 0;
ctrl->xfered1 = 0;
ctrl->cbbytes = 0;
@@ -526,6 +528,10 @@ GLOBALDEF int FtpOptions(int opt, long val, netbuf
*nControl)
rv = 1;
nControl->idlearg2 = (void *) val;
break;
+ case FTPLIB_CALLBACKARG3:
+ rv = 1;
+ nControl->idlearg3 = (void *) val;
+ break;
case FTPLIB_CALLBACKBYTES:
rv = 1;
nControl->cbbytes = (int) val;
@@ -717,6 +723,7 @@ static int FtpOpenPort(netbuf *nControl, netbuf **nData,
int mode, int dir)
ctrl->idletime = nControl->idletime;
ctrl->idlearg = nControl->idlearg;
ctrl->idlearg2 = nControl->idlearg2;
+ ctrl->idlearg3 = nControl->idlearg3;
ctrl->xfered = 0;
ctrl->xfered1 = 0;
ctrl->cbbytes = nControl->cbbytes;
@@ -897,7 +904,7 @@ GLOBALDEF int FtpRead(void *buf, int max, netbuf *nData)
nData->xfered1 += i;
if (nData->xfered1 > nData->cbbytes)
{
- if (nData->idlecb(nData, nData->xfered, nData->idlearg,
nData->idlearg2) == 0)
+ if (nData->idlecb(nData, nData->xfered, nData->idlearg,
nData->idlearg2, nData->idlearg3) == 0)
return 0;
nData->xfered1 = 0;
}
@@ -928,7 +935,7 @@ GLOBALDEF int FtpWrite(void *buf, int len, netbuf *nData)
nData->xfered1 += i;
if (nData->xfered1 > nData->cbbytes)
{
- nData->idlecb(nData, nData->xfered, nData->idlearg,
nData->idlearg2);
+ nData->idlecb(nData, nData->xfered, nData->idlearg,
nData->idlearg2, nData->idlearg3);
nData->xfered1 = 0;
}
}
@@ -1405,6 +1412,7 @@ GLOBALREF int HttpConnect(const char *host, unsigned
short port, netbuf **nContr
ctrl->idletime.tv_sec = ctrl->idletime.tv_usec = 0;
ctrl->idlearg = NULL;
ctrl->idlearg2 = NULL;
+ ctrl->idlearg3 = NULL;
ctrl->xfered = 0;
ctrl->xfered1 = 0;
ctrl->cbbytes = 0;
diff --git a/lib/libftp/ftplib.h b/lib/libftp/ftplib.h
index efbe56f..3776619 100644
--- a/lib/libftp/ftplib.h
+++ b/lib/libftp/ftplib.h
@@ -59,13 +59,14 @@
#define FTPLIB_CALLBACKARG 4
#define FTPLIB_CALLBACKBYTES 5
#define FTPLIB_CALLBACKARG2 6
+#define FTPLIB_CALLBACKARG3 7
#ifdef __cplusplus
extern "C" {
#endif
typedef struct NetBuf netbuf;
-typedef int (*FtpCallback)(netbuf *nControl, int xfered, void *arg, void
*arg2);
+typedef int (*FtpCallback)(netbuf *nControl, int xfered, void *arg, void
*arg2, void *arg3);
/* v1 compatibility stuff */
#if !defined(_FTPLIB_NO_COMPAT)
diff --git a/lib/libpacman/server.c b/lib/libpacman/server.c
index 10af0d4..a7c9fce 100644
--- a/lib/libpacman/server.c
+++ b/lib/libpacman/server.c
@@ -158,7 +158,7 @@ int _pacman_downloadfiles(pmlist_t *servers, const char
*localpath, pmlist_t *fi
int _pacman_downloadfiles_forreal(pmlist_t *servers, const char *localpath,
pmlist_t *files, const char *mtime1, char *mtime2)
{
- int fsz, howmany;
+ int fsz, howmany, remain;
netbuf *control = NULL;
pmlist_t *lp;
int done = 0;
@@ -228,6 +228,7 @@ int _pacman_downloadfiles_forreal(pmlist_t *servers, const
char *localpath,
FtpOptions(FTPLIB_IDLETIME, (long)1000, control);
FtpOptions(FTPLIB_CALLBACKARG, (long)&fsz, control);
FtpOptions(FTPLIB_CALLBACKARG2, (long)&howmany, control);
+ FtpOptions(FTPLIB_CALLBACKARG3, 0, control);
FtpOptions(FTPLIB_CALLBACKBYTES, (10*1024), control);
}
}
@@ -235,6 +236,7 @@ int _pacman_downloadfiles_forreal(pmlist_t *servers, const
char *localpath,
/* get each file in the list */
for(lp = files; lp; lp = lp->next) {
char *fn = (char *)lp->data;
+ remain = howmany - _pacman_list_count(lp) + 1;
if(_pacman_list_is_strin(fn, complete)) {
continue;
@@ -421,6 +423,7 @@ int _pacman_downloadfiles_forreal(pmlist_t *servers, const
char *localpath,
FtpOptions(FTPLIB_IDLETIME, (long)1000, control);
FtpOptions(FTPLIB_CALLBACKARG, (long)&fsz, control);
FtpOptions(FTPLIB_CALLBACKARG2, (long)&howmany, control);
+
FtpOptions(FTPLIB_CALLBACKARG3, (long)&remain, control);
FtpOptions(FTPLIB_CALLBACKBYTES, (10*1024), control);
}
}
@@ -496,7 +499,7 @@ int _pacman_downloadfiles_forreal(pmlist_t *servers, const
char *localpath,
if(!strcmp(server->protocol, "file")) {
EVENT(handle->trans, PM_TRANS_EVT_RETRIEVE_LOCAL, pm_dlfnm, server->path);
} else if(pm_dlcb) {
- pm_dlcb(control,
fsz-*pm_dloffset, &fsz, &howmany);
+ pm_dlcb(control,
fsz-*pm_dloffset, &fsz, &howmany, &remain);
}
complete = _pacman_list_add(complete, fn);
/* rename "output.part" file to "output" file */
diff --git a/src/pacman-g2/download.c b/src/pacman-g2/download.c
index 34e35f0..5a8b4c3 100644
--- a/src/pacman-g2/download.c
+++ b/src/pacman-g2/download.c
@@ -45,17 +45,17 @@ struct timeval t0, t;
float rate;
int xfered1;
unsigned int eta_h, eta_m, eta_s;
-static int remain = 1;
/* pacman options */
extern config_t *config;
extern unsigned int maxcols;
-int log_progress(PM_NETBUF *ctl, int xfered, void *arg, void *arg2)
+int log_progress(PM_NETBUF *ctl, int xfered, void *arg, void *arg2, void *arg3)
{
int fsz = *(int*)arg;
int howmany = *(int*)arg2;
+ int remain = *(int*)arg3;
int pct = ((float)(xfered+offset) / fsz) * 100;
static int lastpct=0;
unsigned int i, cur;
@@ -109,7 +109,6 @@ int log_progress(PM_NETBUF *ctl, int xfered, void *arg,
void *arg2)
putchar('(');
for(i = 0; i<(int)log10(howmany)-(int)log10(remain); i++)
putchar(' ');
-
printf("%d/%d) %s [", remain, howmany, sync_fnm);
cur = (int)((maxcols-68)*pct/100);
for(i = 0; i < maxcols-68; i++) {
@@ -147,7 +146,6 @@ int log_progress(PM_NETBUF *ctl, int xfered, void *arg,
void *arg2)
}
if(lastpct != 100 && pct == 100) {
printf("\n");
- remain = remain + 1;
}
lastcur = cur;
lastpct = pct;
diff --git a/src/pacman-g2/download.h b/src/pacman-g2/download.h
index 9667767..e0f3417 100644
--- a/src/pacman-g2/download.h
+++ b/src/pacman-g2/download.h
@@ -30,7 +30,7 @@ extern float rate;
extern int xfered1;
extern unsigned int eta_h, eta_m, eta_s;
-int log_progress(PM_NETBUF *ctl, int xfered, void *arg, void *arg2);
+int log_progress(PM_NETBUF *ctl, int xfered, void *arg, void *arg2, void
*arg3);
#endif /* _PM_DOWNLOAD_H */
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git