Reduce use of tus_servers.h

parent a92058b2
......@@ -34,11 +34,8 @@
#include <cache/cache.h>
#include <vrt_obj.h>
#include "vcc_tus_if.h"
#include "tus_checksums.h"
#include "tus_file.h"
#include "tus_servers.h"
#include "tus_hdr.h"
#include "tus_response.h"
......@@ -51,19 +48,19 @@ static VCL_BYTES
tus_upload_length(const struct VPFX(tus_server) *tussrv,
const struct tus_file_core *fcore)
{
VCL_BYTES max;
VCL_BYTES srvmax, max;
struct statvfs fs;
CHECK_OBJ_NOTNULL(tussrv, VMOD_TUS_SERVER_MAGIC);
srvmax = tus_server_max(tussrv);
if (fcore != NULL && fcore->fd >= 0) {
if (fstatvfs(fcore->fd, &fs))
return (tussrv->max);
} else if (statvfs(tussrv->basedir, &fs))
return (tussrv->max);
return (srvmax);
} else if (statvfs(tus_server_basedir(tussrv), &fs))
return (srvmax);
max = fs.f_bavail * fs.f_frsize;
return (max < tussrv->max ? max : tussrv->max);
return (max < srvmax ? max : srvmax);
}
static void
......@@ -101,7 +98,6 @@ tus_response(VRT_CTX, const struct VPFX(tus_server) *tussrv,
char buf[TUS_PATH_MAX];
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(tussrv, VMOD_TUS_SERVER_MAGIC);
CHECK_OBJ_NOTNULL(resp, VMOD_TUS_RESPONSE_MAGIC);
if (resp->fcore) {
fcore = resp->fcore;
......@@ -211,14 +207,12 @@ tus_response(VRT_CTX, const struct VPFX(tus_server) *tussrv,
}
VCL_BOOL
tus_done(VRT_CTX, const struct VPFX(tus_server) *tussrv,
const struct tus_response *resp, const char *url)
tus_done(VRT_CTX, const struct tus_response *resp, const char *url)
{
struct tus_file_core *fcore;
struct tus_file_disk *fdisk;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(tussrv, VMOD_TUS_SERVER_MAGIC);
CHECK_OBJ_NOTNULL(resp, VMOD_TUS_RESPONSE_MAGIC);
fcore = resp->fcore;
if (fcore == NULL)
......
......@@ -45,8 +45,7 @@ void
tus_response(VRT_CTX, const struct VPFX(tus_server) *tussrv,
const struct tus_response *resp);
VCL_BOOL
tus_done(VRT_CTX, const struct VPFX(tus_server) *tussrv,
const struct tus_response *resp, const char *url);
tus_done(VRT_CTX, const struct tus_response *resp, const char *url);
VCL_BOOL
tus_meta(VRT_CTX, const struct tus_response *resp, const char *k, VCL_BLOB *b);
......
......@@ -488,7 +488,7 @@ VCL_BOOL tus_server_done(VRT_CTX, struct VPFX(tus_server) *tussrv,
if (args->valid_location)
url = args->location;
return (tus_done(ctx, tussrv, r, url));
return (tus_done(ctx, r, url));
}
VCL_BOOL
......
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