RPM Package Manager, CVS Repository
http://rpm5.org/cvs/
____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson
Root: /v/rpm/cvs Email: [EMAIL PROTECTED]
Module: rpm Date: 07-Jul-2008 18:50:21
Branch: HEAD Handle: 2008070716502001
Modified files:
rpm CHANGES
rpm/rpmio rpmsw.h rpmwget.c
Log:
- rpmwget: wire up --quota.
- rpmsw: change bytes accumulator to unsigned long long.
Summary:
Revision Changes Path
1.2468 +2 -0 rpm/CHANGES
2.11 +1 -1 rpm/rpmio/rpmsw.h
1.14 +40 -7 rpm/rpmio/rpmwget.c
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: rpm/CHANGES
============================================================================
$ cvs diff -u -r1.2467 -r1.2468 CHANGES
--- rpm/CHANGES 7 Jul 2008 04:25:33 -0000 1.2467
+++ rpm/CHANGES 7 Jul 2008 16:50:20 -0000 1.2468
@@ -1,5 +1,7 @@
5.1.0 -> 5.2a0:
+ - jbj: rpmwget: wire up --quota.
+ - jbj: rpmsw: change bytes accumulator to unsigned long long.
- jbj: rpmwget: wire up --limit-rate. more to do ...
- jbj: rpmwget: wire up --progress; only "bar|none" args implemented.
- jbj: rpmwget: add rate/eta calculation to progress bar and logging.
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/rpmsw.h
============================================================================
$ cvs diff -u -r2.10 -r2.11 rpmsw.h
--- rpm/rpmio/rpmsw.h 24 Feb 2008 06:50:23 -0000 2.10
+++ rpm/rpmio/rpmsw.h 7 Jul 2008 16:50:21 -0000 2.11
@@ -33,7 +33,7 @@
struct rpmop_s {
struct rpmsw_s begin; /*!< Starting time stamp. */
int count; /*!< Number of operations. */
- size_t bytes; /*!< Number of bytes transferred. */
+ unsigned long long bytes; /*!< Number of bytes transferred. */
rpmtime_t usecs; /*!< Number of ticks. */
};
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/rpmwget.c
============================================================================
$ cvs diff -u -r1.13 -r1.14 rpmwget.c
--- rpm/rpmio/rpmwget.c 6 Jul 2008 21:16:46 -0000 1.13
+++ rpm/rpmio/rpmwget.c 7 Jul 2008 16:50:21 -0000 1.14
@@ -156,11 +156,11 @@
int dns_timeout_secs; /*!< --dns-timeout ... */
int connect_timeout_secs; /*!< --connect-timeout ... */
int read_timeout_secs; /*!< --read-timeout ... */
- int quota; /*!< -Q,--quota ... */
+ unsigned long long quota; /*!< -Q,--quota ... (in kB) */
int wait_secs; /*!< -w,--wait ... */
int waitretry_secs; /*!< --waitretry ... */
int randomwaitretry_secs; /*!< --random-wait ... */
- double limit_rate; /*!< --limit-rate ... */
+ double limit_rate; /*!< --limit-rate ... (in
kB/s) */
int bind_address; /*!< --bind-address ... */
const char * prefer; /*!< --prefer-family ... */
const char * document_file; /*!< -O,--output-document ... */
@@ -681,7 +681,7 @@
wget->ofd = NULL;
/* Timestamp the output file on success. */
- if (lastModified > 0 && rc == 0) {
+ if (rc == 0 && lastModified > 0) {
struct utimbuf stamp;
stamp.actime = lastModified;
stamp.modtime = lastModified;
@@ -705,6 +705,16 @@
rc = wgetCopyFile(wget);
} while (rc != 0 && (wget->ntries <= 0 || ++wget->ntry < wget->ntries));
+ /* Quota check (if requested) */
+ if (wget->quota > 0) {
+ rpmop top = &wget->top;
+ if ((top->bytes/1024) > wget->quota) {
+fprintf(stderr, "Download quota of %lluK EXCEEDED!\n",
+ (unsigned long long) wget->quota);
+ rc = 1;
+ }
+ }
+
return rc;
}
@@ -787,9 +797,10 @@
/*==============================================================*/
enum {
- POPTWGET_RESTRICT = -2048, /* --restrict-file-names */
- POPTWGET_PROGRESS = -2049, /* --progress */
- POPTWGET_LIMITRATE = -2050, /* --limit-rate */
+ POPTWGET_RESTRICT = -2048, /* --restrict-file-names */
+ POPTWGET_PROGRESS = -2049, /* --progress */
+ POPTWGET_LIMITRATE = -2050, /* --limit-rate */
+ POPTWGET_QUOTA = -2051, /* -Q,--quota */
};
/**
@@ -809,6 +820,28 @@
/* XXX avoid accidental collisions with POPT_BIT_SET for flags */
if (opt->arg == NULL)
switch (opt->val) {
+ case POPTWGET_QUOTA:
+ {
+ char * end = NULL;
+ unsigned long long d = strtoll(arg, &end, 0);
+
+ if (*end == 'g' || *end == 'G') {
+ d *= (1024 * 1024 * 1024); end++;
+ } else
+ if (*end == 'm' || *end == 'M') {
+ d *= (1024 * 1024); end++;
+ } else
+ if (*end == 'k' || *end == 'K') {
+ d *= 1024; end++;
+ } else {
+ d += 1023; /* round up to next kB */
+ }
+
+ if (*end == '\0')
+ wget->quota = d / 1024;
+ else
+fprintf(stderr, "Invalid --quota arg ignored: %s\n", arg);
+ } break;
case POPTWGET_LIMITRATE:
{
char * end = NULL;
@@ -951,7 +984,7 @@
N_("wait from 0...2*WAIT secs between retrievals."), NULL },
{ "no-proxy", '\0', POPT_BIT_SET, &rpmioWDLFlags, WDL_FLAGS_NOPROXY,
N_("explicitly turn off proxy."), NULL },
- { "quota", 'Q', POPT_ARG_INT, &__rpmwget.quota, 0,
+ { "quota", 'Q', POPT_ARG_STRING, 0, POPTWGET_QUOTA,
N_("set retrieval quota to NUMBER."), N_("NUMBER") },
/* XXX add IP addr parsing */
@@ .
______________________________________________________________________
RPM Package Manager http://rpm5.org
CVS Sources Repository [email protected]