Skip to content

Commit

Permalink
#2226 Ensure to close files
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Oct 26, 2021
1 parent c7a446d commit d9bfdb4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ScalliGraph
10 changes: 4 additions & 6 deletions thehive/app/org/thp/thehive/services/AttachmentSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ class AttachmentSrv @Inject() (configuration: Configuration, storageSrv: Storage
val hs = hashers.fromPath(file.filepath)
val id = hs.head.toString
val is = Files.newInputStream(file.filepath)
val result =
storageSrv
.saveBinary("attachment", id, is)
.flatMap(_ => createEntity(Attachment(file.filename, Files.size(file.filepath), file.contentType, hs, id)))
is.close()
result
try storageSrv
.saveBinary("attachment", id, is)
.flatMap(_ => createEntity(Attachment(file.filename, Files.size(file.filepath), file.contentType, hs, id)))
finally is.close()
}

def create(filename: String, contentType: String, data: Array[Byte])(implicit
Expand Down

0 comments on commit d9bfdb4

Please sign in to comment.