mirror of https://github.com/borgbackup/borg.git
Buffer might already be full when chunker_fill is called.
This commit is contained in:
parent
8cc92d896d
commit
599292650c
|
@ -116,17 +116,19 @@ chunker_free(Chunker *c)
|
||||||
static int
|
static int
|
||||||
chunker_fill(Chunker *c)
|
chunker_fill(Chunker *c)
|
||||||
{
|
{
|
||||||
|
size_t n;
|
||||||
memmove(c->data, c->data + c->last, c->position + c->remaining - c->last);
|
memmove(c->data, c->data + c->last, c->position + c->remaining - c->last);
|
||||||
c->position -= c->last;
|
c->position -= c->last;
|
||||||
c->last = 0;
|
c->last = 0;
|
||||||
if(c->eof) {
|
n = c->buf_size - c->position - c->remaining;
|
||||||
|
if(c->eof || n == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
PyObject *data = PyObject_CallMethod(c->fd, "read", "i", c->buf_size - c->position - c->remaining);
|
PyObject *data = PyObject_CallMethod(c->fd, "read", "i", n);
|
||||||
if(!data) {
|
if(!data) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int n = PyBytes_Size(data);
|
n = PyBytes_Size(data);
|
||||||
if(n) {
|
if(n) {
|
||||||
memcpy(c->data + c->position + c->remaining, PyBytes_AsString(data), n);
|
memcpy(c->data + c->position + c->remaining, PyBytes_AsString(data), n);
|
||||||
c->remaining += n;
|
c->remaining += n;
|
||||||
|
|
Loading…
Reference in New Issue