Issue Details (XML | Word | Printable)

Key: IZPACK-10
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Jeff Gordon
Reporter: Jeff Gordon
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
IzPack

Single Instance

Created: 09/Feb/08 11:30 AM   Updated: 19/Apr/08 03:00 PM   Resolved: 14/Apr/08 05:12 PM
Return to search
Component/s: Installer
Affects Version/s: None
Fix Version/s: 4.0.0

Time Tracking:
Not Specified


 Description  « Hide

Provide a common way to detect a running instance, such as a lock file, and shut down the second instance with a warning message.



Julien Ponge made changes - 09/Feb/08 11:59 AM
Field Original Value New Value
Component/s Installer [ 13123 ]
Julien Ponge added a comment - 09/Feb/08 12:08 PM

Julien Ponge added a comment - 12/Feb/08 10:18 AM

Assigned to Jeff with the initial target being v4.0.0.


Julien Ponge made changes - 12/Feb/08 10:18 AM
Assignee Jeff Gordon [ jeffgordon ]
Fix Version/s 4.0.0 [ 14071 ]
Julien Ponge added a comment - 29/Feb/08 08:29 AM

Jeff, do you have any news concerning this issue?

Thanks


Julien Ponge made changes - 06/Apr/08 12:54 PM
Assignee Jeff Gordon [ jeffgordon ]
Fix Version/s 4.0.0 [ 14071 ]
Jeff Gordon added a comment - 14/Apr/08 05:12 PM

I added the method below to com.izforge.izpack.installer.GUIInstaller and did a bit of
testing on Windows (the only thing I have accessible at the moment). It uses the app
name so other installers can run simultaneously.

If there's no objection, I'll commit it.

  • Jeff

private void checkLockFile() throws Exception {
String tempDir = System.getProperty("java.io.tmpdir");
String appName = this.installdata.info.getAppName();
String fileName = "iz-"appName".tmp";
Debug.trace("Making temp file: "+fileName);
Debug.trace("In temp directory: "+tempDir);
File file = new File(tempDir, fileName);
if (file.exists()) {
// Ask user if they want to proceed.
Debug.trace("Lock File Exists, asking user for permission to proceed.");
StringBuffer msg = new StringBuffer();
msg.append("The "appName" installer you are attempting to run seems to have a
copy already running. \n\n");
msg.append("This could be from a previous failed installation attempt or you
may have accidentally launched \n");
msg.append("the installer twice. The recommended action is to select 'No' below
and wait for the other copy \n");
msg.append("of the installer to start. If you are sure there is no other copy
of the installer running click \n");
msg.append("the 'Yes' button to allow this installer to run. \n\n");
msg.append("Are you sure you want to proceed with this installation?");
int status = JOptionPane.showConfirmDialog(null, msg.toString(), "Warning",
JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
if (status == JOptionPane.YES_OPTION) { // Take control of the file so it gets deleted after this installer instance exits. Debug.trace("Setting temp file to delete on exit"); file.deleteOnExit(); } else { // Leave the file as it is. Debug.trace("Leaving temp file alone and exiting"); System.exit(1); }
} else {
try {
// Create the new lock file
if (file.createNewFile()) { Debug.trace("Temp file created"); file.deleteOnExit(); } else { Debug.trace("Temp file could not be created"); Debug.trace("*** Multiple instances of installer will be allowed ***"); }
} catch (Exception e) { Debug.trace("Temp file could not be created: "+e); Debug.trace("*** Multiple instances of installer will be allowed ***"); }
}
}


Jeff Gordon made changes - 14/Apr/08 05:12 PM
Assignee Jeff Gordon [ jeffgordon ]
Resolution Fixed [ 1 ]
Fix Version/s 4.0.0 [ 14071 ]
Status Open [ 1 ] Resolved [ 5 ]
Julien Ponge added a comment - 14/Apr/08 05:20 PM

Good fix.

The only issue is that it is not internationalized, but in the same time this appears before any language choice has been made...

I haven't checked, but could you verify if the default option of the message box is the one that you suggest in the text?


Jeff Gordon added a comment - 14/Apr/08 06:08 PM

I figured if I tried to localize it then I would need to localize all the surrounding methods and potentially introduce a new bug. Maybe a new issue should get created to provide earlier localization support. I'll change the type of option dialog to allow control of the initial selected item.


Julien Ponge made changes - 19/Apr/08 03:00 PM
Status Resolved [ 5 ] Closed [ 6 ]