From 34b10921cedb78b44ce2c4b7e71bf8a04299fdd0 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Wed, 23 Sep 2026 15:26:58 +0200 Subject: [PATCH] re-implemented dia-conversion Signed-off-by: Stephan Richter --- .../de/srsoftware/umbrella/files/FileModule.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/files/src/main/java/de/srsoftware/umbrella/files/FileModule.java b/files/src/main/java/de/srsoftware/umbrella/files/FileModule.java index eb854863..189eda07 100644 --- a/files/src/main/java/de/srsoftware/umbrella/files/FileModule.java +++ b/files/src/main/java/de/srsoftware/umbrella/files/FileModule.java @@ -10,6 +10,7 @@ import static de.srsoftware.umbrella.core.constants.Text.LONG; import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*; import static de.srsoftware.umbrella.core.model.Translatable.t; import static de.srsoftware.umbrella.files.Constants.*; +import static java.lang.System.Logger.Level.WARNING; import static java.net.HttpURLConnection.HTTP_OK; import static java.nio.charset.StandardCharsets.UTF_8; import static java.text.MessageFormat.format; @@ -54,6 +55,18 @@ public class FileModule extends BaseHandler implements FileService { ModuleRegistry.add(this); } + private void convertDia(File source) { + if (!new File("/usr/bin/dia").exists()) return; + var dest = source+".svg"; + String[] command = {"dia","-e",dest,source.toString()}; + try { + Runtime.getRuntime().exec(command); + } catch (IOException e) { + LOG.log(WARNING,"Failed to convert {} to SVG file",source,e); + } + + } + @Override public boolean doDelete(de.srsoftware.tools.Path path, HttpExchange ex) throws IOException { addCors(ex); @@ -200,6 +213,7 @@ public class FileModule extends BaseHandler implements FileService { body.transferTo(out); body.close(); out.close(); + if (filename.toLowerCase().endsWith(".dia")) convertDia(file); } else { if (file.exists()) throw unprocessable("{file} already exists!",FILE, filename); try {