fix insee lock

This commit is contained in:
François
2022-01-27 09:22:53 +01:00
parent bca1181b8b
commit cb7e8d110c
6 changed files with 93 additions and 72 deletions

View File

@ -18,8 +18,10 @@ public class LaunchAdecWatt {
// ========================================
static public void main (String[] args) {
try {
System.err.println ("Config...");
Config.setPWD (LaunchAdecWatt.class);
Config.load ("AdecWatt");
System.err.println ("Bundle...");
Bundle.load ("Help");
Bundle.load ("ToolBar");
Bundle.load ("Proxy");
@ -29,8 +31,6 @@ public class LaunchAdecWatt {
Bundle.load ("AdecWatt");
Bundle.load (JProp.AdecWattUser);
updateShell ();
final AdecWatt adecWatt = new AdecWatt ();
SwingUtilities.invokeLater (new Runnable () {
public void run () {
@ -42,36 +42,37 @@ public class LaunchAdecWatt {
} catch (Exception e) {
File softDir = new File (Config.getPWD ().getParentFile (), "soft");
File jar = new File (softDir, "UpdatedAdecWatt.jar");
System.err.println ("RemoteUpdate...");
RemoteUpdate.launch (jar);
}
}
public static void updateShell () {
try {
File dir = Config.getPWD ().getParentFile ();
File oldLaunch = new File (dir, "launch-lightPlot.sh");
File softDir = new File (dir, "soft");
File newJar = new File (softDir, "AdecWatt.jar");
File oldJar = new File (softDir, "LightPlot.jar");
if (newJar.length () < 1024)
return;
if (oldLaunch.length () > 70) {
PrintWriter pw = new PrintWriter (oldLaunch);
pw.println ("#!/bin/bash");
pw.println ("cd `dirname \"$0\"`");
pw.println ("java -jar soft/AdecWatt.jar");
pw.flush ();
pw.close ();
JOptionPane.showMessageDialog (null,
"Votre logiciel a \u00E9t\u00E9 mis \u00E0 jour.\n"+
"Vous devez relancer l'application\n", "Information", JOptionPane.ERROR_MESSAGE);
System.exit (0);
}
if (oldJar.exists ())
oldJar.delete ();
} catch (FileNotFoundException e) {
}
}
// public static void updateShell () {
// try {
// File dir = Config.getPWD ().getParentFile ();
// File oldLaunch = new File (dir, "launch-lightPlot.sh");
// File softDir = new File (dir, "soft");
// File newJar = new File (softDir, "AdecWatt.jar");
// File oldJar = new File (softDir, "LightPlot.jar");
// if (newJar.length () < 1024)
// return;
// if (oldLaunch.length () > 70) {
// PrintWriter pw = new PrintWriter (oldLaunch);
// pw.println ("#!/bin/bash");
// pw.println ("cd `dirname \"$0\"`");
// pw.println ("java -jar soft/AdecWatt.jar");
// pw.flush ();
// pw.close ();
// JOptionPane.showMessageDialog (null,
// "Votre logiciel a \u00E9t\u00E9 mis \u00E0 jour.\n"+
// "Vous devez relancer l'application\n", "Information", JOptionPane.ERROR_MESSAGE);
// System.exit (0);
// }
// if (oldJar.exists ())
// oldJar.delete ();
// } catch (FileNotFoundException e) {
// }
// }
// ========================================
}

View File

@ -9,6 +9,7 @@ public class LaunchUpdatedAdecWatt {
// ========================================
static public void main (String[] args) {
System.err.println ("LaunchUpdatedAdecWatt...");
Config.setPWD (LaunchUpdatedAdecWatt.class);
File dir = Config.getPWD ().getParentFile ();
RemoteUpdate.renameNewFile (dir);

View File

@ -77,7 +77,11 @@ public class AdecWatt extends StateNotifier {
iconDB.reload ();
imageDB.reload ();
permanentDB.reload ();
inseeDB = InseeDB.readDocument (Config.getDataUrl ("data", "server", "Insee.xml"));
(new Thread () {
public void run () {
inseeDB = InseeDB.readDocument (Config.getDataUrl ("data", "server", "Insee.xml"));
}
}).start ();
broadcastUpdate (BroadcastUnitRoots);
}

View File

@ -114,6 +114,7 @@ public class PermanentDB {
try {
if (file.length () == 0)
continue;
Log.writeLog ("PermanentDB", "load "+srcDir+"/"+file.getName ());
FileInputStream fileInputStream = new FileInputStream (file);
Unit<?> unit = Unit.getInstanceFromStream (adecWatt, fileInputStream, file,
serverToken.equals (srcDir) ? UnitLocation.Server : UnitLocation.Local);