Gitlab Community Edition Instance
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cdstar
cdstar
Commits
3d3ae40c
Commit
3d3ae40c
authored
May 18, 2022
by
mhellka
Browse files
TUS: Apply default expire time to on-disk chunks after restart
parent
a2744151
Changes
2
Hide whitespace changes
Inline
Side-by-side
cdstar-plugins-pom/cdstar-tus/src/main/java/de/gwdg/cdstar/rest/ext/tus/TusBlueprint.java
View file @
3d3ae40c
...
...
@@ -3,7 +3,6 @@ package de.gwdg.cdstar.rest.ext.tus;
import
java.io.IOException
;
import
java.nio.channels.FileChannel
;
import
java.nio.file.StandardOpenOption
;
import
java.time.Duration
;
import
java.time.Instant
;
import
java.util.Date
;
...
...
@@ -32,7 +31,6 @@ public class TusBlueprint implements RestBlueprint {
private
static
final
String
TUS_VERSION
=
"1.0.0"
;
private
final
TusService
chunkService
;
private
Duration
defaultExpire
=
Duration
.
ofHours
(
24
);
public
TusBlueprint
(
TusService
service
)
{
chunkService
=
service
;
...
...
@@ -62,7 +60,6 @@ public class TusBlueprint implements RestBlueprint {
final
TusFile
chunk
=
chunkService
.
createChunk
();
chunk
.
setLength
(
length
);
chunk
.
setMeta
(
meta
);
chunk
.
expireIn
(
defaultExpire
);
ctx
.
status
(
201
);
ctx
.
header
(
TUS_RESUMABLE
,
TUS_VERSION
);
...
...
cdstar-plugins-pom/cdstar-tus/src/main/java/de/gwdg/cdstar/rest/ext/tus/TusService.java
View file @
3d3ae40c
...
...
@@ -3,6 +3,7 @@ package de.gwdg.cdstar.rest.ext.tus;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.time.Duration
;
import
java.time.Instant
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -29,6 +30,7 @@ public class TusService {
public
static
final
String
pluginName
=
"tus-upload"
;
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
TusService
.
class
);
private
Duration
defaultExpire
=
Duration
.
ofHours
(
24
);
Path
basePath
;
Map
<
String
,
TusFile
>
chunks
=
new
ConcurrentHashMap
<>();
...
...
@@ -44,6 +46,7 @@ public class TusService {
try
(
Stream
<
Path
>
s
=
Files
.
list
(
basePath
))
{
s
.
filter
(
this
::
isChunk
).
forEach
(
path
->
{
final
TusFile
chunk
=
new
TusFile
(
chunkNameFormPath
(
path
),
path
);
chunk
.
expireIn
(
defaultExpire
);
chunks
.
put
(
chunk
.
getName
(),
chunk
);
});
}
...
...
@@ -89,6 +92,7 @@ public class TusService {
final
String
id
=
Utils
.
bytesToHex
(
Utils
.
randomBytes
(
16
));
final
Path
path
=
basePath
.
resolve
(
chunkFileName
(
id
));
chunk
=
new
TusFile
(
id
,
path
);
chunk
.
expireIn
(
defaultExpire
);
}
while
(
chunks
.
putIfAbsent
(
chunk
.
getName
(),
chunk
)
!=
null
);
return
chunk
;
...
...
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