From 655310a270f115c10880281f219ea069a028f4ab Mon Sep 17 00:00:00 2001 From: Douglas Gillespie <50671166+douggillespie@users.noreply.github.com> Date: Wed, 20 Nov 2024 09:23:36 +0000 Subject: [PATCH] V2.02.14b Fix XML writer bug Add code to remove old garbage from log file folder --- .classpath | 2 +- dependency-reduced-pom.xml | 42 ++++++++++++---- pom.xml | 2 +- src/PamController/PamFolders.java | 54 +++++++++++++++++++++ src/PamController/PamguardVersionInfo.java | 4 +- src/PamModel/PamModel.java | 1 - src/nidaqdev/NIDaqParams.java | 3 ++ src/pamguard/Pamguard.java | 7 +++ src/simulatedAcquisition/SimParameters.java | 3 ++ 9 files changed, 104 insertions(+), 14 deletions(-) diff --git a/.classpath b/.classpath index 26c568d7..6086187c 100644 --- a/.classpath +++ b/.classpath @@ -6,7 +6,7 @@ - + diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index 7e9cf300..b4f35b83 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -4,7 +4,7 @@ org.pamguard Pamguard Pamguard - 2.02.14a + 2.02.14b Pamguard using Maven to control dependencies www.pamguard.org @@ -137,6 +137,13 @@ + + maven-surefire-plugin + 3.5.1 + + false + + @@ -163,19 +170,25 @@ bedatadriven public repo https://nexus.bedatadriven.com/content/groups/public/ - - - false - - talan - talan - https://nexus.talanlabs.com/content/repositories/releases/ - central https://repo1.maven.org/maven2 + + + org.junit.jupiter + junit-jupiter + 5.11.3 + test + + + junit-jupiter-params + org.junit.jupiter + + + + @@ -185,6 +198,17 @@ + + + + org.junit + junit-bom + 5.11.3 + pom + import + + + 11 11 diff --git a/pom.xml b/pom.xml index 6f154ee6..9994e6dc 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.pamguard Pamguard - 2.02.14a + 2.02.14b Pamguard Pamguard using Maven to control dependencies www.pamguard.org diff --git a/src/PamController/PamFolders.java b/src/PamController/PamFolders.java index c84df304..e93dcbc2 100644 --- a/src/PamController/PamFolders.java +++ b/src/PamController/PamFolders.java @@ -1,6 +1,9 @@ package PamController; import java.io.File; +import java.io.FilenameFilter; + +import org.apache.commons.io.filefilter.FileFilterUtils; import PamUtils.FileFunctions; @@ -143,6 +146,57 @@ public class PamFolders { return homeFolder; } + /** + * Delete temporary files that get dumped in the homd folder, but not deleted properly + * if PAMGuard crashes. It's possible that some may be locked by the current, or other + * running processes, so don't worry too much if some can't delete. + * @param string file mask for deleteion + */ + public static boolean deleteTempFiles(String fileMask) { + return deleteTempFiles(getHomeFolder(), fileMask); + } + + public static boolean deleteTempFiles(String root, String fileMask) { + File rootFolder = new File(root); + if (rootFolder.exists() == false) { + return false; + } + String[] files = null; + try { + files = rootFolder.list(new FilenameFilter() { + + @Override + public boolean accept(File dir, String name) { + if (name.endsWith(fileMask)) { + return true; + } + return false; + } + }); + } + catch (Exception e) { + return false; + } + if (files == null) return true; + int success = 0; + int fail = 0; + for (int i = 0; i < files.length; i ++) { + try { + File aFile = new File(root + File.separator + files[i]); + if (aFile.delete()) { + success++; + } + else { + fail++; + } + } + catch (Exception e) { + System.out.printf("Unable to delete temp file %s\n", files[i]); + } + } + return true; + } + } diff --git a/src/PamController/PamguardVersionInfo.java b/src/PamController/PamguardVersionInfo.java index a88775d5..e7cfbed4 100644 --- a/src/PamController/PamguardVersionInfo.java +++ b/src/PamController/PamguardVersionInfo.java @@ -31,12 +31,12 @@ public class PamguardVersionInfo { * Version number, major version.minorversion.sub-release. * Note: can't go higher than sub-release 'f' */ - static public final String version = "2.02.14a"; + static public final String version = "2.02.14b"; /** * Release date */ - static public final String date = " 28 October 2024"; + static public final String date = " 20 November 2024"; // /** // * Release type - Beta or Core diff --git a/src/PamModel/PamModel.java b/src/PamModel/PamModel.java index fa58a450..d54ce031 100644 --- a/src/PamModel/PamModel.java +++ b/src/PamModel/PamModel.java @@ -1091,7 +1091,6 @@ final public class PamModel implements PamSettings { // clear the current list pluginList.clear(); daqList.clear(); - /* * If developing a new PAMPlugin in eclipse, the easiest way to do it is to make a new * Eclipse project for your plugin code. Within that project, copy this PamModel class diff --git a/src/nidaqdev/NIDaqParams.java b/src/nidaqdev/NIDaqParams.java index 7ed75965..46ce3093 100644 --- a/src/nidaqdev/NIDaqParams.java +++ b/src/nidaqdev/NIDaqParams.java @@ -82,6 +82,9 @@ public class NIDaqParams extends SoundCardParameters implements Serializable, Cl } PamParameterSet ps = super.getParameterSet(); + if (ps == null) { + return null; + } try { Field field = this.getClass().getDeclaredField("aiRange"); ps.put(new PrivatePamParameterData(this, field) { diff --git a/src/pamguard/Pamguard.java b/src/pamguard/Pamguard.java index fb8847c7..378cb525 100644 --- a/src/pamguard/Pamguard.java +++ b/src/pamguard/Pamguard.java @@ -42,6 +42,7 @@ import com.formdev.flatlaf.FlatLightLaf; import Acquisition.FolderInputSystem; import PamController.PamController; +import PamController.PamFolders; import PamController.PamGUIManager; import PamController.PamRunModeDialog; import PamController.PamRunModeParams; @@ -722,6 +723,12 @@ public class Pamguard { private static class FolderSizeMonitor implements Runnable { @Override public void run() { + + PamFolders.deleteTempFiles(".x86_64.dll"); + PamFolders.deleteTempFiles(".dll.lck"); + PamFolders.deleteTempFiles(".tmp"); + PamFolders.deleteTempFiles("-sqlitejdbc.dll"); + while(true) { long length = 0; File dir = new File(getSettingsFolder()); diff --git a/src/simulatedAcquisition/SimParameters.java b/src/simulatedAcquisition/SimParameters.java index b82ff2a7..85c72f94 100644 --- a/src/simulatedAcquisition/SimParameters.java +++ b/src/simulatedAcquisition/SimParameters.java @@ -87,6 +87,9 @@ public class SimParameters extends SoundCardParameters implements Cloneable, Ser } PamParameterSet ps = super.getParameterSet(); + if (ps == null) { + return null; + } try { Field field = this.getClass().getDeclaredField("simObjects"); ps.put(new PrivatePamParameterData(this, field) {