re-implemented dia-conversion

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2026-09-23 15:26:58 +02:00
parent ed863548b2
commit 34b10921ce
@@ -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 {