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
e38b73d2
Unverified
Commit
e38b73d2
authored
Sep 08, 2020
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handle file size vs. upload_offset during load
parent
1b4b025d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
tus_file.c
src/tus_file.c
+20
-0
No files found.
src/tus_file.c
View file @
e38b73d2
...
...
@@ -590,6 +590,7 @@ tus_file_add(struct VPFX(tus_server) *srv, int basefd, const char *filename)
struct
stat
st
;
int
fd
=
-
1
;
const
char
*
err
;
ssize_t
sz
;
if
(
fstatat
(
basefd
,
filename
,
&
st
,
AT_SYMLINK_NOFOLLOW
))
{
fprintf
(
stderr
,
"tus add stat %s: %d
\n
"
,
filename
,
errno
);
...
...
@@ -634,6 +635,25 @@ tus_file_add(struct VPFX(tus_server) *srv, int basefd, const char *filename)
goto
err
;
}
sz
=
(
uintmax_t
)
st
.
st_size
-
header_size
;
assert
(
sz
>=
0
);
/*
* if data was written before we updated the offset,
* we truncate to avoid potentially corrupted data
*/
if
(
fdisk
->
location_length
>
0
)
{
// .done() called & truncated
}
else
if
(
fdisk
->
upload_offset
<
sz
)
{
AZ
(
ftruncate
(
fd
,
header_size
+
fdisk
->
upload_offset
));
fprintf
(
stderr
,
"tus add %s: truncated to %zd
\n
"
,
filename
,
sz
);
}
else
if
(
fdisk
->
upload_offset
>
sz
)
{
fprintf
(
stderr
,
"tus add %s: updated offset from %zd to %zd
\n
"
,
filename
,
fdisk
->
upload_offset
,
sz
);
fdisk
->
upload_offset
=
sz
;
}
/* note: the close can cause a SIGSEGV if a file is unlinked
* concurrently. But as we should be the only user of the base
* directory, that should not happen
...
...
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