rename url_path -> upload_path

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