From f68b6fd4e27af7584f75d6c90b6be044a4ac33ef Mon Sep 17 00:00:00 2001 From: hillp Date: Thu, 19 Jun 2025 08:24:59 -0600 Subject: [PATCH 1/2] Added replace existing option to Files.copy in order to fix attachments not being copied properly --- .../org/phoebus/applications/logbook/InMemoryLogClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/logbook/inmemory/src/main/java/org/phoebus/applications/logbook/InMemoryLogClient.java b/app/logbook/inmemory/src/main/java/org/phoebus/applications/logbook/InMemoryLogClient.java index 826155d52f..5650bfa031 100644 --- a/app/logbook/inmemory/src/main/java/org/phoebus/applications/logbook/InMemoryLogClient.java +++ b/app/logbook/inmemory/src/main/java/org/phoebus/applications/logbook/InMemoryLogClient.java @@ -128,7 +128,7 @@ public LogEntry set(LogEntry log) { ext = file.getName().substring(i); } File tempFile = File.createTempFile(prefix, ext); - Files.copy(file.toPath(), tempFile.toPath()); + Files.copy(file.toPath(), tempFile.toPath(), StandardCopyOption.REPLACE_EXISTING); tempFile.deleteOnExit(); String mimeType = URLConnection.guessContentTypeFromName(tempFile.getName()); return AttachmentImpl.of(tempFile, mimeType != null ? mimeType : ext, false); From b13d0374669da97e1bd38fa46ad1f701623e9797 Mon Sep 17 00:00:00 2001 From: hillp Date: Thu, 19 Jun 2025 08:35:22 -0600 Subject: [PATCH 2/2] Added missing import --- .../java/org/phoebus/applications/logbook/InMemoryLogClient.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/logbook/inmemory/src/main/java/org/phoebus/applications/logbook/InMemoryLogClient.java b/app/logbook/inmemory/src/main/java/org/phoebus/applications/logbook/InMemoryLogClient.java index 5650bfa031..3dfce4258c 100644 --- a/app/logbook/inmemory/src/main/java/org/phoebus/applications/logbook/InMemoryLogClient.java +++ b/app/logbook/inmemory/src/main/java/org/phoebus/applications/logbook/InMemoryLogClient.java @@ -23,6 +23,7 @@ import java.io.InputStream; import java.net.URLConnection; import java.nio.file.Files; +import java.nio.file.StandardCopyOption; import java.time.Instant; import java.util.Arrays; import java.util.Collection;