Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-tus
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-tus
Commits
a1db091f
Unverified
Commit
a1db091f
authored
May 20, 2022
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename url_path -> upload_path
parent
44d85a71
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
32 deletions
+32
-32
tus_file.c
src/tus_file.c
+23
-23
tus_file.h
src/tus_file.h
+5
-5
tus_request.c
src/tus_request.c
+3
-3
tus_response.c
src/tus_response.c
+1
-1
No files found.
src/tus_file.c
View file @
a1db091f
...
@@ -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 u
rl
_path */
/* extract u
pload
_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
->
u
rl
_path
);
VSB_cat
(
vsb
,
fdisk
->
u
pload
_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
->
u
rl
_path
);
l
=
strlen
(
basename
)
+
strlen
(
fdisk
->
u
pload
_path
);
assert
(
l
<
TUS_PATH_MAX
);
assert
(
l
<
TUS_PATH_MAX
);
p
=
strrchr
(
fdisk
->
u
rl
_path
,
'/'
);
p
=
strrchr
(
fdisk
->
u
pload
_path
,
'/'
);
AN
(
p
);
AN
(
p
);
p
++
;
p
++
;
AN
(
*
p
);
AN
(
*
p
);
l
=
fdisk
->
u
rl
_path_length
+
strlen
(
basename
)
-
strlen
(
p
);
l
=
fdisk
->
u
pload
_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
->
u
rl
_path_length
=
l
;
fdisk
->
u
pload
_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 u
rl
_path %s
\n
"
,
fprintf
(
stderr
,
"tus add %s: duplicate u
pload
_path %s
\n
"
,
filename
,
fdisk
->
u
rl
_path
);
filename
,
fdisk
->
u
pload
_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
*
u
rl
_path
)
tus_file_lookup
(
struct
VPFX
(
tus_server
)
*
srv
,
const
char
*
u
pload
_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
(
u
rl
_path
);
unsigned
l
=
strlen
(
u
pload
_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
.
u
rl_path
,
url
_path
);
strcpy
(
needle
.
u
pload_path
,
upload
_path
);
needle
.
u
rl
_path_length
=
l
;
needle
.
u
pload
_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
*
u
rl
_path
,
const
char
*
id
,
const
char
*
metadata
,
const
char
*
u
pload
_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
(
u
rl
_path
)
+
l
>
TUS_PATH_MAX
)
{
if
(
strlen
(
u
pload
_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
),
u
rl
_path
);
tus_server_name
(
srv
),
u
pload
_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
->
u
rl_path_length
=
strlen
(
url
_path
);
fdisk
->
u
pload_path_length
=
strlen
(
upload
_path
);
AN
(
fdisk
->
u
rl
_path_length
);
AN
(
fdisk
->
u
pload
_path_length
);
strcpy
(
fdisk
->
u
rl_path
,
url
_path
);
strcpy
(
fdisk
->
u
pload_path
,
upload
_path
);
if
(
u
rl_path
[
fdisk
->
url
_path_length
-
1
]
!=
'/'
)
if
(
u
pload_path
[
fdisk
->
upload
_path_length
-
1
]
!=
'/'
)
fdisk
->
u
rl_path
[
fdisk
->
url
_path_length
++
]
=
'/'
;
fdisk
->
u
pload_path
[
fdisk
->
upload
_path_length
++
]
=
'/'
;
strcpy
(
fdisk
->
u
rl_path
+
fdisk
->
url
_path_length
,
id
);
strcpy
(
fdisk
->
u
pload_path
+
fdisk
->
upload
_path_length
,
id
);
fdisk
->
u
rl
_path_length
+=
strlen
(
id
);
fdisk
->
u
pload
_path_length
+=
strlen
(
id
);
assert
(
fdisk
->
u
rl
_path_length
<
TUS_PATH_MAX
);
assert
(
fdisk
->
u
pload
_path_length
<
TUS_PATH_MAX
);
if
(
metadata
&&
*
metadata
!=
'\0'
)
{
if
(
metadata
&&
*
metadata
!=
'\0'
)
{
fdisk
->
metadata_length
=
strlen
(
metadata
);
fdisk
->
metadata_length
=
strlen
(
metadata
);
...
...
src/tus_file.h
View file @
a1db091f
...
@@ -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
u
rl
_path
[
TUS_PATH_MAX
];
char
u
pload
_path
[
TUS_PATH_MAX
];
unsigned
guard_magic
;
unsigned
guard_magic
;
unsigned
u
rl
_path_length
;
unsigned
u
pload
_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
->
u
rl_path
,
TUS_PATH_MAX
)
!=
d
->
url
_path_length
)
if
(
strnlen
(
d
->
u
pload_path
,
TUS_PATH_MAX
)
!=
d
->
upload
_path_length
)
return
(
"u
rl
_path_length mismatch"
);
return
(
"u
pload
_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
->
u
rl_path
,
bb
->
url
_path
));
return
(
strcmp
(
aa
->
u
pload_path
,
bb
->
upload
_path
));
}
}
VSPLAY_HEAD
(
tus_files
,
tus_file_core
);
VSPLAY_HEAD
(
tus_files
,
tus_file_core
);
...
...
src/tus_request.c
View file @
a1db091f
...
@@ -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
->
u
rl
_path
,
'/'
);
p
=
strrchr
(
fdisk
->
u
pload
_path
,
'/'
);
AN
(
p
);
AN
(
p
);
WS_VSB_new
(
vsb
,
ctx
->
ws
);
WS_VSB_new
(
vsb
,
ctx
->
ws
);
VSB_bcat
(
vsb
,
fdisk
->
u
rl_path
,
(
p
-
fdisk
->
url
_path
)
+
1
);
VSB_bcat
(
vsb
,
fdisk
->
u
pload_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
->
u
rl
_path
);
http_SetH
(
ctx
->
http_req
,
HTTP_HDR_URL
,
fdisk
->
u
pload
_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"
,
...
...
src/tus_response.c
View file @
a1db091f
...
@@ -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
->
u
rl
_path
);
fdisk
->
u
pload
_path
);
}
}
switch
(
fdisk
->
type
)
{
switch
(
fdisk
->
type
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment