Skip to content

Commit

Permalink
Merge pull request #3068 from ControlSystemStudio/CSSTUDIO-2460
Browse files Browse the repository at this point in the history
CSSTUDIO-2460 Bugfix for the Logbook application: Delete temporary file when file attachment object is garbage collected.
  • Loading branch information
shroffk authored Jul 8, 2024
2 parents 35a1d20 + a0423e6 commit 187d6b6
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,14 @@ private void fetchAttachments() {
Collection<Attachment> attachments = logEntry.getAttachments().stream()
.filter((attachment) -> attachment.getName() != null && !attachment.getName().isEmpty())
.map((attachment) -> {
OlogAttachment fileAttachment = new OlogAttachment();
OlogAttachment fileAttachment = new OlogAttachment() {
@Override
protected void finalize() {
if (getFile() != null && getFile().exists()) {
getFile().delete();
}
}
};
fileAttachment.setContentType(attachment.getContentType());
fileAttachment.setThumbnail(false);
fileAttachment.setFileName(attachment.getName());
Expand Down

0 comments on commit 187d6b6

Please sign in to comment.