{
struct archive_read *a = (struct archive_read *)_a;
struct archive_read_filter *f = a->filter;
- /* XXX handle n == -1 */
+ /* We use n == -1 for 'the last filter', which is always the client proxy. */
+ if (n == -1 && f != NULL) {
+ struct archive_read_filter *last = f;
+ f = f->upstream;
+ while (f != NULL) {
+ last = f;
+ f = f->upstream;
+ }
+ return (last);
+ }
if (n < 0)
return NULL;
while (n > 0 && f != NULL) {
bytes_read = (filter->read)(filter,
&filter->client_buff);
if (bytes_read < 0) { /* Read error. */
+fprintf(stderr, "Filter read ahead saw bytes_read=%d\n", bytes_read);
filter->client_total = filter->client_avail = 0;
filter->client_next = filter->client_buff = NULL;
filter->fatal = 1;
bytes_read = (filter->read)(filter, &filter->client_buff);
if (bytes_read < 0) {
+ fprintf(stderr, "Filter skip saw bytes_read=%d\n", bytes_read);
filter->client_buff = NULL;
filter->fatal = 1;
return (bytes_read);