diff --git a/src/main/java/org/cryptomator/common/mountpoint/MountPointChooser.java b/src/main/java/org/cryptomator/common/mountpoint/MountPointChooser.java index 3a4d82cf3..1e36ba5f6 100644 --- a/src/main/java/org/cryptomator/common/mountpoint/MountPointChooser.java +++ b/src/main/java/org/cryptomator/common/mountpoint/MountPointChooser.java @@ -1,6 +1,6 @@ package org.cryptomator.common.mountpoint; -import com.google.common.base.Preconditions; +import dagger.multibindings.IntKey; import org.cryptomator.common.vaults.Volume; import java.nio.file.Path; @@ -12,13 +12,13 @@ import java.util.SortedSet; * preparation of a mountpoint or an exception otherwise.
*

All MountPointChoosers (MPCs) need to implement this class and must be added to * the pool of possible MPCs by the {@link MountPointChooserModule MountPointChooserModule.} - * The MountPointChooserModule will sort them according to their {@link #getPriority() priority.} + * The MountPointChooserModule will sort them according to their {@link IntKey IntKey priority.} * The priority must be defined by the developer to reflect a useful execution order.
* A specific priority must not be assigned to more than one MPC at a time; * the result of having two MPCs with equal priority is undefined. * - *

MPCs are executed by a {@link Volume} in ascending order of their priority - * (smaller priorities are tried first) to find and prepare a suitable mountpoint for the volume. + *

MPCs are executed by a {@link Volume} in descending order of their priority + * (higher priorities are tried first) to find and prepare a suitable mountpoint for the volume. * The volume has access to a {@link SortedSet} of MPCs in this specific order, * that is provided by the Module. The Set contains all available Choosers, even if they * are not {@link #isApplicable(Volume) applicable} for the Vault/Volume. The Volume must diff --git a/src/main/java/org/cryptomator/common/mountpoint/MountPointChooserModule.java b/src/main/java/org/cryptomator/common/mountpoint/MountPointChooserModule.java index cfb7b68ec..9c7893e42 100644 --- a/src/main/java/org/cryptomator/common/mountpoint/MountPointChooserModule.java +++ b/src/main/java/org/cryptomator/common/mountpoint/MountPointChooserModule.java @@ -9,6 +9,7 @@ import dagger.multibindings.IntoMap; import org.cryptomator.common.vaults.PerVault; import javax.inject.Named; +import java.util.Comparator; import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; @@ -24,16 +25,22 @@ public abstract class MountPointChooserModule { @Binds @IntoMap - @IntKey(0) + @IntKey(1000) @PerVault public abstract MountPointChooser bindCustomMountPointChooser(CustomMountPointChooser chooser); @Binds @IntoMap - @IntKey(100) + @IntKey(900) @PerVault public abstract MountPointChooser bindCustomDriveLetterChooser(CustomDriveLetterChooser chooser); + @Binds + @IntoMap + @IntKey(800) + @PerVault + public abstract MountPointChooser bindAvailableDriveLetterChooser(AvailableDriveLetterChooser chooser); + @Binds @IntoMap @IntKey(101) @@ -42,13 +49,7 @@ public abstract class MountPointChooserModule { @Binds @IntoMap - @IntKey(200) - @PerVault - public abstract MountPointChooser bindAvailableDriveLetterChooser(AvailableDriveLetterChooser chooser); - - @Binds - @IntoMap - @IntKey(999) + @IntKey(100) @PerVault public abstract MountPointChooser bindTemporaryMountPointChooser(TemporaryMountPointChooser chooser); @@ -56,7 +57,8 @@ public abstract class MountPointChooserModule { @PerVault @Named("orderedMountPointChoosers") public static Iterable provideOrderedMountPointChoosers(Map choosers) { - SortedMap sortedChoosers = new TreeMap<>(choosers); + SortedMap sortedChoosers = new TreeMap<>(Comparator.reverseOrder()); + sortedChoosers.putAll(choosers); return Iterables.unmodifiableIterable(sortedChoosers.values()); } }