From f489693d6a0ab96dc13fb8c9148de59809fca075 Mon Sep 17 00:00:00 2001 From: Tres Finocchiaro Date: Tue, 11 Jan 2022 11:09:51 -0500 Subject: [PATCH] Fix log zipping with OneDrive Desktop folder --- src/qz/utils/FileUtilities.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/qz/utils/FileUtilities.java b/src/qz/utils/FileUtilities.java index 4e02b9c49..f25cb33c4 100644 --- a/src/qz/utils/FileUtilities.java +++ b/src/qz/utils/FileUtilities.java @@ -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); @@ -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 */