ソースを参照

Fixed random set order and updated #getAvailableDriveLetter()

Fixed bug introduced by 32a810fe1d0439435045827c5b653a2e10f5c621:
The Set of existing DriveLetters was in random order because Collectors#toUnmodifiableSet is an unordered collector.

Changed #getAvailableDriveLetter() to use Stream#findFirst() instead of #findAny()
JaniruTEC 4 年 前
コミット
597899d2bf

+ 3 - 2
main/commons/src/main/java/org/cryptomator/common/vaults/WindowsDriveLetters.java

@@ -5,6 +5,7 @@
  *******************************************************************************/
 package org.cryptomator.common.vaults;
 
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Sets;
 import org.apache.commons.lang3.SystemUtils;
 
@@ -25,7 +26,7 @@ public final class WindowsDriveLetters {
 
 	static {
 		try (IntStream stream = IntStream.rangeClosed('C', 'Z')) {
-			C_TO_Z = stream.mapToObj(i -> String.valueOf((char) i)).collect(Collectors.toUnmodifiableSet());
+			C_TO_Z = stream.mapToObj(i -> String.valueOf((char) i)).collect(ImmutableSet.toImmutableSet());
 		}
 	}
 
@@ -51,7 +52,7 @@ public final class WindowsDriveLetters {
 	}
 
 	public Optional<String> getAvailableDriveLetter() {
-		return getAvailableDriveLetters().stream().findAny();
+		return getAvailableDriveLetters().stream().findFirst();
 	}
 
 	public Optional<Path> getAvailableDriveLetterPath() {