Sfoglia il codice sorgente

prevent regressions for google drive preset

Armin Schrenk 2 anni fa
parent
commit
8c34fc76c5

+ 2 - 3
src/main/java/module-info.java

@@ -2,8 +2,7 @@ import ch.qos.logback.classic.spi.Configurator;
 import org.cryptomator.common.locationpresets.DropboxLinuxLocationPresetsProvider;
 import org.cryptomator.common.locationpresets.DropboxMacLocationPresetsProvider;
 import org.cryptomator.common.locationpresets.DropboxWindowsLocationPresetsProvider;
-import org.cryptomator.common.locationpresets.GoogleDriveWindowsLocationPresetsProvider;
-import org.cryptomator.common.locationpresets.GoogleDriveMacLocationPresetsProvider;
+import org.cryptomator.common.locationpresets.GoogleDriveLocationPresetsProvider;
 import org.cryptomator.common.locationpresets.ICloudMacLocationPresetsProvider;
 import org.cryptomator.common.locationpresets.ICloudWindowsLocationPresetsProvider;
 import org.cryptomator.common.locationpresets.LocationPresetsProvider;
@@ -57,7 +56,7 @@ open module org.cryptomator.desktop {
 	provides LocationPresetsProvider with DropboxMacLocationPresetsProvider, //
 			DropboxWindowsLocationPresetsProvider, DropboxLinuxLocationPresetsProvider, //
 			ICloudMacLocationPresetsProvider, ICloudWindowsLocationPresetsProvider, //
-			GoogleDriveWindowsLocationPresetsProvider, GoogleDriveMacLocationPresetsProvider, //
+			GoogleDriveLocationPresetsProvider, //
 			PCloudLocationPresetsProvider, MegaLocationPresetsProvider, //
 			OneDriveLinuxLocationPresetsProvider, OneDriveWindowsLocationPresetsProvider, //
 			OneDriveMacLocationPresetsProvider;

+ 37 - 0
src/main/java/org/cryptomator/common/locationpresets/GoogleDriveLocationPresetsProvider.java

@@ -0,0 +1,37 @@
+package org.cryptomator.common.locationpresets;
+
+import org.cryptomator.integrations.common.CheckAvailability;
+import org.cryptomator.integrations.common.OperatingSystem;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.stream.Stream;
+
+import static org.cryptomator.integrations.common.OperatingSystem.Value.MAC;
+import static org.cryptomator.integrations.common.OperatingSystem.Value.WINDOWS;
+
+@OperatingSystem(WINDOWS)
+@OperatingSystem(MAC)
+@CheckAvailability
+public final class GoogleDriveLocationPresetsProvider implements LocationPresetsProvider {
+
+	private static final Path LOCATION1 = LocationPresetsProvider.resolveLocation("~/GoogleDrive");
+	private static final Path LOCATION2 = LocationPresetsProvider.resolveLocation("~/GoogleDrive/My Drive");
+
+
+	@CheckAvailability
+	public static boolean isPresent() {
+		return Files.isDirectory(LOCATION1) || Files.isDirectory(LOCATION2);
+	}
+
+	@Override
+	public Stream<LocationPreset> getLocations() {
+		if(Files.isDirectory(LOCATION1)) {
+			return Stream.of(new LocationPreset("Google Drive", LOCATION1));
+		} else if(Files.isDirectory(LOCATION2)) {
+			return Stream.of(new LocationPreset("Google Drive", LOCATION2));
+		} else {
+			return Stream.of();
+		}
+	}
+}

+ 0 - 29
src/main/java/org/cryptomator/common/locationpresets/GoogleDriveMacLocationPresetsProvider.java

@@ -1,29 +0,0 @@
-package org.cryptomator.common.locationpresets;
-
-import org.cryptomator.integrations.common.CheckAvailability;
-import org.cryptomator.integrations.common.OperatingSystem;
-
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.stream.Stream;
-
-import static org.cryptomator.integrations.common.OperatingSystem.Value.MAC;
-import static org.cryptomator.integrations.common.OperatingSystem.Value.WINDOWS;
-
-@OperatingSystem(MAC)
-@CheckAvailability
-public final class GoogleDriveMacLocationPresetsProvider implements LocationPresetsProvider {
-
-	private static final Path LOCATION = LocationPresetsProvider.resolveLocation("~/Google Drive/My Drive");
-
-
-	@CheckAvailability
-	public static boolean isPresent() {
-		return Files.isDirectory(LOCATION);
-	}
-
-	@Override
-	public Stream<LocationPreset> getLocations() {
-		return Stream.of(new LocationPreset("Google Drive", LOCATION));
-	}
-}

+ 0 - 28
src/main/java/org/cryptomator/common/locationpresets/GoogleDriveWindowsLocationPresetsProvider.java

@@ -1,28 +0,0 @@
-package org.cryptomator.common.locationpresets;
-
-import org.cryptomator.integrations.common.CheckAvailability;
-import org.cryptomator.integrations.common.OperatingSystem;
-
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.stream.Stream;
-
-import static org.cryptomator.integrations.common.OperatingSystem.Value.WINDOWS;
-
-@OperatingSystem(WINDOWS)
-@CheckAvailability
-public final class GoogleDriveWindowsLocationPresetsProvider implements LocationPresetsProvider {
-
-	private static final Path LOCATION = LocationPresetsProvider.resolveLocation("~/Google Drive");
-
-
-	@CheckAvailability
-	public static boolean isPresent() {
-		return Files.isDirectory(LOCATION);
-	}
-
-	@Override
-	public Stream<LocationPreset> getLocations() {
-		return Stream.of(new LocationPreset("Google Drive", LOCATION));
-	}
-}