Skip to content

Commit 187d6b6

Browse files
authored
Merge pull request #3068 from ControlSystemStudio/CSSTUDIO-2460
CSSTUDIO-2460 Bugfix for the Logbook application: Delete temporary file when file attachment object is garbage collected.
2 parents 35a1d20 + a0423e6 commit 187d6b6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/SingleLogEntryDisplayController.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,14 @@ private void fetchAttachments() {
188188
Collection<Attachment> attachments = logEntry.getAttachments().stream()
189189
.filter((attachment) -> attachment.getName() != null && !attachment.getName().isEmpty())
190190
.map((attachment) -> {
191-
OlogAttachment fileAttachment = new OlogAttachment();
191+
OlogAttachment fileAttachment = new OlogAttachment() {
192+
@Override
193+
protected void finalize() {
194+
if (getFile() != null && getFile().exists()) {
195+
getFile().delete();
196+
}
197+
}
198+
};
192199
fileAttachment.setContentType(attachment.getContentType());
193200
fileAttachment.setThumbnail(false);
194201
fileAttachment.setFileName(attachment.getName());

0 commit comments

Comments
 (0)