The included patch adds an option --max-bytes to the ftp/http/hftp methods of
debmirror that allows to limit the amount of data downloaded.
This feature is convenient e.g. for volume based DSL subscriptions to max
out the remaining bandwidth at the end of a statement period.
--- debmirror.orig 2005-01-29 11:48:48.000000000 +0100
+++ debmirror 2005-01-29 12:58:20.000000000 +0100
@@ -222,6 +222,10 @@
Download at most max-batch number of files (and ignore rest).
+=item --max-bytes=number
+
+Download at most max-bytes bytes of data (and ignore rest).
+
=item --rsync-batch=number
Download at most number of files with each rsync call and then loop.
@@ -316,6 +320,7 @@
my $timeout=300;
my $max_batch=0;
my $rsync_batch=200;
+my $max_bytes=0;
my $num_errors=0;
my $bytes_to_get=0;
my $bytes_gotten=0;
@@ -360,6 +365,7 @@
'timeout|t=s' => \$timeout,
'max-batch=s' => \$max_batch,
'rsync-batch=s' => \$rsync_batch,
+ 'max-bytes=s' => \$max_bytes,
'ignore-missing-release' => \$ignore_release,
'ignore-release-gpg' => \$ignore_release_gpg,
'dry-run' => \$dry_run_var,
@@ -398,6 +404,7 @@
}
say("Proxy: $proxy.") if $proxy;
say("Download at most $max_batch files.") if ($max_batch > 0);
+say("Download at most $max_bytes bytes of data.") if ($max_bytes > 0);
say("Download at most $rsync_batch files per rsync call.") if ($download_method eq "rsync");
say("Dry run.") if $dry_run_var;
@@ -731,6 +738,11 @@
$num_errors++;
last;
}
+ if ($max_bytes > 0 && $bytes_gotten >= $max_bytes) {
+ push (@errlog,"Bytes limit exceeded, mirror run was partial\n");
+ $num_errors++;
+ last;
+ }
}
}
last DOWNLOAD;
@@ -751,6 +763,11 @@
$num_errors++;
last;
}
+ if ($max_bytes > 0 && $bytes_gotten >= $max_bytes) {
+ push (@errlog,"Bytes limit exceeded, mirror run was partial\n");
+ $num_errors++;
+ last;
+ }
}
}
last DOWNLOAD;
@@ -771,6 +788,11 @@
$num_errors++;
last;
}
+ if ($max_bytes > 0 && $bytes_gotten >= $max_bytes) {
+ push (@errlog,"Bytes limit exceeded, mirror run was partial\n");
+ $num_errors++;
+ last;
+ }
}
}
last DOWNLOAD;