Skip to content

Commit

Permalink
Send guessed challenge when running from IDE (qzind#1147)
Browse files Browse the repository at this point in the history
Closes qzind#1141
  • Loading branch information
tresf authored Jun 22, 2023
1 parent 47e17ad commit 42ba86a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions .idea/runConfigurations/App.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 19 additions & 4 deletions src/qz/utils/SystemUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.logging.log4j.Logger;
import qz.common.Constants;
import qz.common.TrayManager;
import qz.installer.Installer;

import javax.swing.*;
import java.awt.*;
Expand Down Expand Up @@ -773,12 +774,26 @@ public static String calculateSaltedChallenge() {
}

private static long calculateChallenge() {
if(getJarPath() != null) {
if (getJarPath().toFile().exists()) {
return getJarPath().toFile().lastModified();
Path jarPath;
if(SystemUtilities.isJar()) {
jarPath = getJarPath();
} else {
// Running from IDE: Try to guess .jar location
if(SystemUtilities.isMac()) {
// 2.2+
jarPath = Paths.get(Installer.getInstance().getDestination(), "Contents", "Resources", Constants.PROPS_FILE + ".jar");
if(!jarPath.toFile().exists()) {
// 2.1
jarPath = Paths.get(Installer.getInstance().getDestination(), Constants.PROPS_FILE + ".jar");
}
} else {
jarPath = Paths.get(Installer.getInstance().getDestination(), Constants.PROPS_FILE + ".jar");
}
}
return -1L; // Fallback when running from IDE
if (jarPath.toFile().exists()) {
return jarPath.toFile().lastModified();
}
return -1L; // Fallback
}

/**
Expand Down

0 comments on commit 42ba86a

Please sign in to comment.