only truncate once for .done()

parent 9e562f0e
......@@ -990,12 +990,13 @@ tus_body_to_file(VRT_CTX, struct tus_file_core *fcore)
VCL_BOOL
tus_file_done(struct tus_file_core *fcore, struct tus_file_disk *fdisk, const char *url)
{
int fd;
int fd, need_truncate;
size_t l = strlen(url);
if (l >= TUS_PATH_MAX)
return (0);
need_truncate = (fdisk->location_length == 0);
strcpy(fdisk->location, url);
fdisk->location_length = l;
......@@ -1007,7 +1008,7 @@ tus_file_done(struct tus_file_core *fcore, struct tus_file_disk *fdisk, const ch
* location
*/
if (fdisk->type == TUS_FINAL)
if (fdisk->type == TUS_FINAL || need_truncate == 0)
return (1);
assert(fdisk->type == TUS_SINGLE);
......
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