Skip to content

Commit

Permalink
Delete empty folder /System BEFORE reassigning _systemLibrariesFolder
Browse files Browse the repository at this point in the history
Otherwise we will try to delete the wrong folder.
This bug would always throw an error on Linux and Windows. The installer
would then stop having completed every step except deleting the empty
System folder.
  • Loading branch information
timcu committed Oct 20, 2022
1 parent c49b1aa commit 7c0100e
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ public File getSystemLibrariesFolder() {
return _systemLibrariesFolder;
}

/**
* This method moves the folders which were designed for macOS
* to the locations required for linux or windows
* If the destination folder is /opt then
* /opt/Library becomes /opt/Local/Library
* /opt/System/Library becomes /opt/Library
* /opt/System is then deleted
* @throws IOException if folders already exist or can't move folders or can't delete empty folder /opt/System
*/
public void renameFolders() throws IOException {
File localFolder = new File(_destinationFolder, "Local");
if (localFolder.exists()) {
Expand All @@ -57,11 +66,12 @@ public void renameFolders() throws IOException {
if (!_systemLibrariesFolder.renameTo(libraryFolder)) {
throw new IOException("Failed to move '" + _systemLibrariesFolder + "' to '" + libraryFolder + "'.");
}
_systemLibrariesFolder = libraryFolder;

// Delete empty folder /opt/System BEFORE reassigning _systemLibrariesFolder otherwise we will lose reference to it
if (!_systemLibrariesFolder.getParentFile().delete()) {
throw new IOException("Failed to delete '" + _systemLibrariesFolder.getParentFile() + ".");
}
_systemLibrariesFolder = libraryFolder;

System.out.println("Done");
}
}

0 comments on commit 7c0100e

Please sign in to comment.