Improve partial local writes

If we can only save part of the request body locally, there is no need to discard
all of it.

Yet, if checksums are enabled, we will still fail later with a 413.
parent 515e0395
......@@ -915,21 +915,21 @@ tus_suck_f(void *priv, unsigned flush, const void *ptr, ssize_t len)
assert(len > 0);
l = write(suck->fd, ptr, len);
if (l > 0) {
*suck->upload_offset += l;
if (*suck->upload_offset > suck->max) {
errno = EFBIG;
return (-1);
}
}
if (l != len)
l = -1;
return (-1);
if (suck->chksum)
tus_chksum_update(suck->ctx, suck->chksum, ptr, len);
if (l <= 0)
return (l);
*suck->upload_offset += l;
if (*suck->upload_offset > suck->max) {
errno = EFBIG;
return (-1);
}
return (0);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment