rename url_path -> upload_path

parent 44d85a71
......@@ -78,7 +78,7 @@ tus_file_final_concat_parse(const char *spec)
vsb = VSB_new_auto();
/* extract url_path */
/* extract upload_path */
while (spec != NULL) {
while (*spec == ' ')
spec++;
......@@ -323,7 +323,7 @@ tus_file_final_urls(VRT_CTX, const struct tus_file_core *fcore, const char *pfx)
if (i > 0)
VSB_cat(vsb, " ");
VSB_cat(vsb, pfx);
VSB_cat(vsb, fdisk->url_path);
VSB_cat(vsb, fdisk->upload_path);
}
return (WS_VSB_finish(vsb, ctx->ws, NULL));
}
......@@ -628,19 +628,19 @@ tus_file_rename_base(struct tus_file_core *fcore, const char *basename)
files = tus_server_files(srv);
// pessimistic
l = strlen(basename) + strlen(fdisk->url_path);
l = strlen(basename) + strlen(fdisk->upload_path);
assert (l < TUS_PATH_MAX);
p = strrchr(fdisk->url_path, '/');
p = strrchr(fdisk->upload_path, '/');
AN(p);
p++;
AN(*p);
l = fdisk->url_path_length + strlen(basename) - strlen(p);
l = fdisk->upload_path_length + strlen(basename) - strlen(p);
tus_server_lock(srv);
check = VSPLAY_REMOVE(tus_files, files, fcore);
assert(check == fcore);
(void) strcpy(p, basename);
fdisk->url_path_length = l;
fdisk->upload_path_length = l;
AZ(VSPLAY_INSERT(tus_files, files, fcore));
tus_server_unlock(srv);
}
......@@ -785,8 +785,8 @@ tus_file_add(struct VPFX(tus_server) *srv, int basefd, const char *filename)
return;
}
fprintf(stderr, "tus add %s: duplicate url_path %s\n",
filename, fdisk->url_path);
fprintf(stderr, "tus add %s: duplicate upload_path %s\n",
filename, fdisk->upload_path);
err:
tus_file_disk_del(&fdisk, &fd, filename, basefd);
......@@ -842,11 +842,11 @@ tus_file_fdisk_init(struct tus_file_disk *fdisk)
/* under tus_server mtx to protect tus_files */
struct tus_file_core *
tus_file_lookup(struct VPFX(tus_server) *srv, const char *url_path)
tus_file_lookup(struct VPFX(tus_server) *srv, const char *upload_path)
{
struct tus_file_core fcore, *found;
struct tus_file_disk needle;
unsigned l = strlen(url_path);
unsigned l = strlen(upload_path);
if (l >= TUS_PATH_MAX) {
errno = ENAMETOOLONG;
......@@ -855,9 +855,9 @@ tus_file_lookup(struct VPFX(tus_server) *srv, const char *url_path)
INIT_OBJ(&fcore, VMOD_TUS_FILE_CORE_MAGIC);
tus_file_fdisk_init(&needle);
strcpy(needle.url_path, url_path);
strcpy(needle.upload_path, upload_path);
needle.url_path_length = l;
needle.upload_path_length = l;
fcore.disk = &needle;
found = VSPLAY_FIND(tus_files, tus_server_files(srv), &fcore);
......@@ -887,7 +887,7 @@ tus_name_rnd(struct vsb *vsb)
/* under tus_server mtx to protect tus_files */
struct tus_file_core *
tus_file_new(VRT_CTX, struct VPFX(tus_server) *srv, enum tus_f_type type,
const char *url_path, const char *id, const char *metadata,
const char *upload_path, const char *id, const char *metadata,
unsigned *status, const char **reason)
{
struct tus_file_core *fcore;
......@@ -913,10 +913,10 @@ tus_file_new(VRT_CTX, struct VPFX(tus_server) *srv, enum tus_f_type type,
}
l++;
if (strlen(url_path) + l > TUS_PATH_MAX) {
if (strlen(upload_path) + l > TUS_PATH_MAX) {
errno = ENAMETOOLONG;
VSLb(ctx->vsl, SLT_Error, "%s: path too long: %s",
tus_server_name(srv), url_path);
tus_server_name(srv), upload_path);
*status = 400;
*reason = "Path too long";
return (NULL);
......@@ -984,14 +984,14 @@ tus_file_new(VRT_CTX, struct VPFX(tus_server) *srv, enum tus_f_type type,
fdisk->type = type;
fdisk->url_path_length = strlen(url_path);
AN(fdisk->url_path_length);
strcpy(fdisk->url_path, url_path);
if (url_path[fdisk->url_path_length - 1] != '/')
fdisk->url_path[fdisk->url_path_length++] = '/';
strcpy(fdisk->url_path + fdisk->url_path_length, id);
fdisk->url_path_length += strlen(id);
assert(fdisk->url_path_length < TUS_PATH_MAX);
fdisk->upload_path_length = strlen(upload_path);
AN(fdisk->upload_path_length);
strcpy(fdisk->upload_path, upload_path);
if (upload_path[fdisk->upload_path_length - 1] != '/')
fdisk->upload_path[fdisk->upload_path_length++] = '/';
strcpy(fdisk->upload_path + fdisk->upload_path_length, id);
fdisk->upload_path_length += strlen(id);
assert(fdisk->upload_path_length < TUS_PATH_MAX);
if (metadata && *metadata != '\0') {
fdisk->metadata_length = strlen(metadata);
......
......@@ -50,9 +50,9 @@ struct tus_file_disk {
unsigned magic;
#define VMOD_TUS_FILE_DISK_MAGIC 0x105f11ed
unsigned version;
char url_path[TUS_PATH_MAX];
char upload_path[TUS_PATH_MAX];
unsigned guard_magic;
unsigned url_path_length;
unsigned upload_path_length;
char metadata[TUS_METADATA_MAX];
unsigned guard2_magic;
unsigned metadata_length;
......@@ -113,8 +113,8 @@ tus_file_disk_err(const struct tus_file_disk *d)
return ("bad guard3_magic");
if (d->version != 2)
return ("version != 2");
if (strnlen(d->url_path, TUS_PATH_MAX) != d->url_path_length)
return ("url_path_length mismatch");
if (strnlen(d->upload_path, TUS_PATH_MAX) != d->upload_path_length)
return ("upload_path_length mismatch");
if (strnlen(d->location, TUS_PATH_MAX) != d->location_length)
return ("location_length mismatch");
if (strnlen(d->metadata, TUS_METADATA_MAX) != d->metadata_length)
......@@ -142,7 +142,7 @@ tus_file_cmp(const struct tus_file_core *a,
bb = b->disk;
CHECK_TUS_FILE_DISK(aa);
CHECK_TUS_FILE_DISK(bb);
return (strcmp(aa->url_path, bb->url_path));
return (strcmp(aa->upload_path, bb->upload_path));
}
VSPLAY_HEAD(tus_files, tus_file_core);
......
......@@ -94,15 +94,15 @@ tus_request_complete(VRT_CTX, const struct VPFX(tus_server) *srv,
if (fdisk->type == TUS_SINGLE)
b = tus_concat_hash(ctx, srv, c);
if (b != NULL) {
p = strrchr(fdisk->url_path, '/');
p = strrchr(fdisk->upload_path, '/');
AN(p);
WS_VSB_new(vsb, ctx->ws);
VSB_bcat(vsb, fdisk->url_path, (p - fdisk->url_path) + 1);
VSB_bcat(vsb, fdisk->upload_path, (p - fdisk->upload_path) + 1);
tus_vsbhex(vsb, b);
http_SetH(ctx->http_req, HTTP_HDR_URL,
WS_VSB_finish(vsb, ctx->ws, NULL));
} else {
http_SetH(ctx->http_req, HTTP_HDR_URL, fdisk->url_path);
http_SetH(ctx->http_req, HTTP_HDR_URL, fdisk->upload_path);
}
http_Unset(ctx->http_req, H_Content_Length);
http_PrintfHeader(ctx->http_req, "Content-Length: %zu",
......
......@@ -186,7 +186,7 @@ tus_response(VRT_CTX, const struct VPFX(tus_server) *tussrv,
if (resp->s.status == 201) {
AN(resp->schemeauth);
http_PrintfHeader(r, "Location: %s%s", resp->schemeauth,
fdisk->url_path);
fdisk->upload_path);
}
switch (fdisk->type) {
......
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