Skip to content

Commit

Permalink
Make legacy (2.0) uninstall tasks conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
tresf committed Jan 25, 2023
1 parent fc2c0d6 commit 560f00a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/qz/installer/Installer.java
Original file line number Diff line number Diff line change
Expand Up @@ -333,4 +333,14 @@ public static Properties persistProperties(File oldFile, Properties newProps) {
public void spawn(String ... args) throws Exception {
spawn(new ArrayList(Arrays.asList(args)));
}

boolean hasVersion_2_0() {
// QZ Tray 2.1 removed the "auth" folder, this should be a valid test
try {
Path p = Paths.get(getDestination(), "auth");
return p.toFile().isDirectory();
}
catch(Exception ignore) {}
return false;
}
}
4 changes: 4 additions & 0 deletions src/qz/installer/LinuxInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ private void addLauncher(String location, boolean isStartup) {
}

public Installer removeLegacyStartup() {
if(!hasVersion_2_0()) {
log.info("{} 2.0 was not found; skipping removal of legacy startup entries", ABOUT_TITLE);
return this;
}
log.info("Removing legacy autostart entries for all users matching {} or {}", ABOUT_TITLE, PROPS_FILE);
// assume users are in /home
String[] shortcutNames = {ABOUT_TITLE, PROPS_FILE};
Expand Down
4 changes: 4 additions & 0 deletions src/qz/installer/MacInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ public Installer removeSystemSettings() {
* Removes legacy (<= 2.0) startup entries
*/
public Installer removeLegacyStartup() {
if(!hasVersion_2_0()) {
log.info("{} 2.0 was not found; skipping removal of legacy startup entries", ABOUT_TITLE);
return this;
}
log.info("Removing startup entries for all users matching " + ABOUT_TITLE);
String script = "tell application \"System Events\" to delete "
+ "every login item where name is \"" + ABOUT_TITLE + "\""
Expand Down
4 changes: 4 additions & 0 deletions src/qz/installer/WindowsInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public void setDestination(String destination) {
* Cycles through registry keys removing legacy (<= 2.0) startup entries
*/
public Installer removeLegacyStartup() {
if(!hasVersion_2_0()) {
log.info("{} 2.0 was not found; skipping removal of legacy startup entries", ABOUT_TITLE);
return this;
}
log.info("Removing legacy startup entries for all users matching " + ABOUT_TITLE);
for (String user : Advapi32Util.registryGetKeys(HKEY_USERS)) {
WindowsUtilities.deleteRegValue(HKEY_USERS, user.trim() + "\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", ABOUT_TITLE);
Expand Down

0 comments on commit 560f00a

Please sign in to comment.