Skip to content

Commit

Permalink
Fix log zipping with OneDrive Desktop folder
Browse files Browse the repository at this point in the history
  • Loading branch information
tresf committed Jan 11, 2022
1 parent 918dcf3 commit f489693
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/qz/utils/FileUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class FileUtilities {
public static boolean zipLogs() {
String date = new SimpleDateFormat("yyyy-MM-dd_HHmm").format(new Date());
String filename = Constants.DATA_DIR + "-" + date + ".zip";
Path destination = Paths.get(System.getProperty("user.home"), "Desktop", filename);
Path destination = getUserDesktop().resolve(filename);

try {
zipDirectory(USER_DIR, destination);
Expand Down Expand Up @@ -101,6 +101,20 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attributes) {
outputStream.close();
}

/**
* Location where user Desktop is located
*/
private static Path getUserDesktop() {
// OneDrive will override the default location on Windows
if(SystemUtilities.isWindows()) {
try {
return Paths.get(WindowsSpecialFolders.DESKTOP.getPath());
}
catch(Throwable ignore) {}
}
return Paths.get(System.getProperty("user.home"), "Desktop");
}

/**
* Location where preferences and logs are kept
*/
Expand Down

0 comments on commit f489693

Please sign in to comment.