Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
memoriav
M
Memobase 2020
S
services
postprocessing
Media Converter
Commits
517c0dde
Unverified
Commit
517c0dde
authored
Dec 07, 2020
by
Sebastian Schüpbach
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
log data copying
Signed-off-by:
Sebastian Schüpbach
<
sebastian.schuepbach@unibas.ch
>
parent
b08eeef1
Pipeline
#18452
passed with stages
in 8 minutes and 7 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
src/main/scala/ch/memobase/DisseminationCopyHandler.scala
src/main/scala/ch/memobase/DisseminationCopyHandler.scala
+7
-5
No files found.
src/main/scala/ch/memobase/DisseminationCopyHandler.scala
View file @
517c0dde
...
...
@@ -19,19 +19,20 @@
package
ch.memobase
import
java.io.
{
ByteArrayOutputStream
,
FileOutputStream
,
IOException
}
import
java.nio.file.
{
Files
,
Path
,
Paths
}
import
ch.memobase.models.
{
Conversions
,
MimeType
}
import
org.apache.logging.log4j.scala.Logging
import
java.io.
{
ByteArrayOutputStream
,
FileOutputStream
,
IOException
}
import
java.nio.file.
{
Files
,
Path
,
Paths
}
import
scala.util.
{
Failure
,
Success
,
Try
}
/**
* Manages dissemination copies of media files
*/
class
DisseminationCopyHandler
(
audioSnippetDuration
:
Int
)
{
class
DisseminationCopyHandler
(
audioSnippetDuration
:
Int
)
extends
Logging
{
private
def
writeData
(
data
:
ByteArrayOutputStream
,
destFile
:
Path
)
:
Try
[
Path
]
=
{
val
inSize
=
data
.
size
Try
(
new
FileOutputStream
(
destFile
.
toFile
))
match
{
case
Success
(
fos
)
=>
try
{
...
...
@@ -40,6 +41,8 @@ class DisseminationCopyHandler(audioSnippetDuration: Int) {
}
catch
{
case
e
:
IOException
=>
Failure
(
e
)
}
finally
{
val
outSize
=
fos
.
getChannel
.
size
logger
.
info
(
s
"$inSize bytes data read, $outSize bytes written for $destFile"
)
fos
.
close
()
data
.
close
()
}
...
...
@@ -73,7 +76,6 @@ class DisseminationCopyHandler(audioSnippetDuration: Int) {
* @return true if both files were overwritten, false otherwise
*/
def
createAudioCopy
(
data
:
ByteArrayOutputStream
,
destFile
:
String
,
sourceFileType
:
MimeType
,
isSnippet
:
Boolean
=
false
)
:
Try
[
Boolean
]
=
Try
{
// FIXME
val
tempFilePath
=
Files
.
createTempFile
(
"media-"
,
"."
+
Conversions
.
getFileTypeExtension
(
sourceFileType
).
get
)
writeData
(
data
,
tempFilePath
)
val
copyRemoved
=
removeExistingFile
(
Paths
.
get
(
destFile
))
...
...
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