Skip to content

Commit

Permalink
Merge pull request #1727 from DSheirer/1726-application-root-dir-on-s…
Browse files Browse the repository at this point in the history
…tartup

#1726 Don't Auto-Create App Root In User Home Directory Once Changed
  • Loading branch information
DSheirer authored Nov 11, 2023
2 parents 2347135 + a1a6b3e commit 672207c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

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

32 changes: 10 additions & 22 deletions src/main/java/io/github/dsheirer/gui/SDRTrunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,10 @@ public SDRTrunk()
}
}

//Setup the application home directory
Path home = getHomePath();

ThreadPool.logSettings();

mLog.info("Home path: " + home.toString());

//Load properties file
if(home != null)
{
loadProperties(home);
}
loadProperties();

//Log current properties setting
SystemProperties.getInstance().logCurrentSettings();
Expand Down Expand Up @@ -632,34 +624,30 @@ private void toggleBroadcastStatusPanelVisibility()
* Loads the application properties file from the user's home directory,
* creating the properties file for the first-time, if necessary
*/
private void loadProperties(Path homePath)
private void loadProperties()
{
Path propsPath = homePath.resolve("SDRTrunk.properties");
Path propertiesPath = mUserPreferences.getDirectoryPreference().getDirectoryApplicationRoot().resolve("SDRTrunk.properties");

if(!Files.exists(propsPath))
if(!Files.exists(propertiesPath))
{
try
{
mLog.info("SDRTrunk - creating application properties file [" +
propsPath.toAbsolutePath() + "]");

Files.createFile(propsPath);
mLog.info("SDRTrunk - creating application properties file [" + propertiesPath.toAbsolutePath() + "]");
Files.createFile(propertiesPath);
}
catch(IOException e)
{
mLog.error("SDRTrunk - couldn't create application properties "
+ "file [" + propsPath.toAbsolutePath(), e);
mLog.error("SDRTrunk - couldn't create application properties file [" + propertiesPath.toAbsolutePath(), e);
}
}

if(Files.exists(propsPath))
if(Files.exists(propertiesPath))
{
SystemProperties.getInstance().load(propsPath);
SystemProperties.getInstance().load(propertiesPath);
}
else
{
mLog.error("SDRTrunk - couldn't find or recreate the SDRTrunk " +
"application properties file");
mLog.error("SDRTrunk - couldn't find or recreate the SDRTrunk application properties file");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,6 @@ public void logCurrentSettings()
{
mLog.info("SystemProperties - no properties file loaded - using defaults");
}
else
{
mLog.info("SystemProperties - application properties loaded [" + mPropertiesPath.toString() + "]");
}
}

/**
Expand Down

0 comments on commit 672207c

Please sign in to comment.