mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-20 19:51:27 +00:00
Apply code suggestions
This commit is contained in:
@@ -2,7 +2,7 @@ import ch.qos.logback.classic.spi.Configurator;
|
||||
import org.cryptomator.common.locationpresets.DropboxMacLocationPresetsProvider;
|
||||
import org.cryptomator.common.locationpresets.DropboxWindowsLocationPresetsProvider;
|
||||
import org.cryptomator.common.locationpresets.GoogleDriveMacLocationPresetsProvider;
|
||||
import org.cryptomator.common.locationpresets.GoogleDriveWindowsLocationPresetsProvider;
|
||||
import org.cryptomator.common.locationpresets.GoogleDriveLocationPresetsProvider;
|
||||
import org.cryptomator.common.locationpresets.ICloudMacLocationPresetsProvider;
|
||||
import org.cryptomator.common.locationpresets.ICloudWindowsLocationPresetsProvider;
|
||||
import org.cryptomator.common.locationpresets.LocationPresetsProvider;
|
||||
@@ -54,7 +54,7 @@ open module org.cryptomator.desktop {
|
||||
provides Configurator with LogbackConfiguratorFactory;
|
||||
provides LocationPresetsProvider with DropboxMacLocationPresetsProvider, //
|
||||
DropboxWindowsLocationPresetsProvider, ICloudMacLocationPresetsProvider, //
|
||||
ICloudWindowsLocationPresetsProvider, GoogleDriveWindowsLocationPresetsProvider, //
|
||||
ICloudWindowsLocationPresetsProvider, GoogleDriveLocationPresetsProvider, //
|
||||
GoogleDriveMacLocationPresetsProvider, PCloudLocationPresetsProvider, //
|
||||
MegaLocationPresetsProvider, OneDriveLocationPresetsProvider, OneDriveWindowsLocationPresetsProvider;
|
||||
}
|
||||
@@ -13,16 +13,23 @@ import static org.cryptomator.integrations.common.OperatingSystem.Value.MAC;
|
||||
@CheckAvailability
|
||||
public final class DropboxMacLocationPresetsProvider implements LocationPresetsProvider {
|
||||
|
||||
private static final Path LOCATION = LocationPresetsProvider.resolveLocation("~/Library/CloudStorage/Dropbox");
|
||||
private static final Path LOCATION1 = LocationPresetsProvider.resolveLocation("~/Library/CloudStorage/Dropbox");
|
||||
private static final Path LOCATION2 = LocationPresetsProvider.resolveLocation("~/Dropbox");
|
||||
|
||||
|
||||
@CheckAvailability
|
||||
public static boolean isPresent() {
|
||||
return Files.isDirectory(LOCATION);
|
||||
return Files.isDirectory(LOCATION1) || Files.isDirectory(LOCATION2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<LocationPreset> getLocations() {
|
||||
return Stream.of(new LocationPreset("Dropbox", LOCATION));
|
||||
if(Files.isDirectory(LOCATION1)) {
|
||||
return Stream.of(new LocationPreset("Dropbox", LOCATION1));
|
||||
} else if(Files.isDirectory(LOCATION2)) {
|
||||
return Stream.of(new LocationPreset("Dropbox", LOCATION2));
|
||||
} else {
|
||||
return Stream.of();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,13 @@ 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 GoogleDriveWindowsLocationPresetsProvider implements LocationPresetsProvider {
|
||||
public final class GoogleDriveLocationPresetsProvider implements LocationPresetsProvider {
|
||||
|
||||
private static final Path LOCATION = LocationPresetsProvider.resolveLocation("~/Google Drive");
|
||||
|
||||
@@ -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.MAC;
|
||||
|
||||
@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));
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public final class OneDriveWindowsLocationPresetsProvider implements LocationPre
|
||||
* @throws CommandFailedException Thrown when the process exit code is non-zero
|
||||
*/
|
||||
@Blocking
|
||||
static void waitForSuccess(Process process, int timeoutSeconds, String cmdDescription) throws TimeoutException, InterruptedException, CommandFailedException {
|
||||
private static void waitForSuccess(Process process, int timeoutSeconds, String cmdDescription) throws TimeoutException, InterruptedException, CommandFailedException {
|
||||
boolean exited = process.waitFor(timeoutSeconds, TimeUnit.SECONDS);
|
||||
if (!exited) {
|
||||
throw new TimeoutException(cmdDescription + " timed out after " + timeoutSeconds + "s");
|
||||
@@ -88,7 +88,7 @@ public final class OneDriveWindowsLocationPresetsProvider implements LocationPre
|
||||
}
|
||||
}
|
||||
|
||||
static class CommandFailedException extends Exception {
|
||||
private static class CommandFailedException extends Exception {
|
||||
|
||||
int exitCode;
|
||||
String stdout;
|
||||
|
||||
Reference in New Issue
Block a user