diff options
author | Ingo Bauersachs <ingo@jitsi.org> | 2015-02-03 22:48:46 +0100 |
---|---|---|
committer | Ingo Bauersachs <ingo@jitsi.org> | 2015-02-03 22:48:46 +0100 |
commit | 5cee50b17e175ee6c4649199437b4eee2ca4828f (patch) | |
tree | e9e3931196f99bbb36c7f67142b696c0cb8a57cc /src/net/java/sip/communicator/launcher/SIPCommunicator.java | |
parent | 99e335d4639559119f148c78b64a9051d2eae405 (diff) | |
download | jitsi-5cee50b17e175ee6c4649199437b4eee2ca4828f.zip jitsi-5cee50b17e175ee6c4649199437b4eee2ca4828f.tar.gz jitsi-5cee50b17e175ee6c4649199437b4eee2ca4828f.tar.bz2 |
Delete the Felix cache folder on a major or minor version change
Diffstat (limited to 'src/net/java/sip/communicator/launcher/SIPCommunicator.java')
-rw-r--r-- | src/net/java/sip/communicator/launcher/SIPCommunicator.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/net/java/sip/communicator/launcher/SIPCommunicator.java b/src/net/java/sip/communicator/launcher/SIPCommunicator.java index 4cc6103..7f3d715 100644 --- a/src/net/java/sip/communicator/launcher/SIPCommunicator.java +++ b/src/net/java/sip/communicator/launcher/SIPCommunicator.java @@ -9,6 +9,7 @@ package net.java.sip.communicator.launcher; import java.awt.*; import java.io.*; +import net.java.sip.communicator.impl.version.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.launchutils.*; @@ -171,12 +172,61 @@ public class SIPCommunicator } } + String currentVersion = + VersionImpl.VERSION_MAJOR + "." + VersionImpl.VERSION_MINOR; + File jitsiVersion + = new File(new File( + System.getProperty(PNAME_SC_CACHE_DIR_LOCATION), + System.getProperty(PNAME_SC_HOME_DIR_NAME)), + ".lastversion"); + if (jitsiVersion.exists()) + { + BufferedReader r = new BufferedReader(new FileReader(jitsiVersion)); + String lastVersion = r.readLine(); + r.close(); + + if (!currentVersion.equals(lastVersion)) + { + File felixCache = + new File(new File( + System.getProperty(PNAME_SC_CACHE_DIR_LOCATION), + System.getProperty(PNAME_SC_HOME_DIR_NAME)), + "sip-communicator.bin"); + if (felixCache.exists()) + { + deleteRecursive(felixCache); + } + } + } + + FileWriter fw = new FileWriter(jitsiVersion); + fw.write(currentVersion); + fw.close(); + //there was no error, continue; System.setOut(new ScStdOut(System.out)); Main.main(new String[0]); } /** + * Recursively delete a directory. + * @param f The directory to the delete. + * @throws IOException + */ + private static void deleteRecursive(File f) throws IOException + { + if (f.isDirectory()) + { + for (File c : f.listFiles()) + { + deleteRecursive(c); + } + } + + f.delete(); + } + + /** * Sets the system properties net.java.sip.communicator.SC_HOME_DIR_LOCATION * and net.java.sip.communicator.SC_HOME_DIR_NAME (if they aren't already * set) in accord with the OS conventions specified by the name of the OS. |