|
@@ -7,6 +7,8 @@ import org.cryptomator.integrations.mount.Mount;
|
|
|
import org.cryptomator.integrations.mount.MountBuilder;
|
|
|
import org.cryptomator.integrations.mount.MountFailedException;
|
|
|
import org.cryptomator.integrations.mount.MountService;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import javax.inject.Inject;
|
|
|
import javax.inject.Named;
|
|
@@ -28,6 +30,8 @@ import static org.cryptomator.integrations.mount.MountCapability.UNMOUNT_FORCED;
|
|
|
@Singleton
|
|
|
public class Mounter {
|
|
|
|
|
|
+ private static final Logger LOG = LoggerFactory.getLogger(Mounter.class);
|
|
|
+
|
|
|
// mount providers (key) can not be used if any of the conflicting mount providers (values) are already in use
|
|
|
private static final Map<String, Set<String>> CONFLICTING_MOUNT_SERVICES = Map.of(
|
|
|
"org.cryptomator.frontend.fuse.mount.MacFuseMountProvider", Set.of("org.cryptomator.frontend.fuse.mount.FuseTMountProvider"),
|
|
@@ -115,8 +119,14 @@ public class Mounter {
|
|
|
Files.createDirectories(defaultMountPointBase);
|
|
|
builder.setMountpoint(defaultMountPointBase);
|
|
|
} else if (canMountToDir) {
|
|
|
- var mountPoint = defaultMountPointBase.resolve(vaultSettings.mountName.get());
|
|
|
+ var dirName = vaultSettings.mountName.get();
|
|
|
+ //required for https://github.com/cryptomator/cryptomator/issues/3272
|
|
|
+ if(service.getClass().getCanonicalName().equals("org.cryptomator.frontend.fuse.mount.FuseTMountProvider")) {
|
|
|
+ dirName = vaultSettings.id;
|
|
|
+ }
|
|
|
+ var mountPoint = defaultMountPointBase.resolve(dirName);
|
|
|
Files.createDirectories(mountPoint);
|
|
|
+ cleanup = () -> removeCreatedDirectory(mountPoint);
|
|
|
builder.setMountpoint(mountPoint);
|
|
|
}
|
|
|
} else {
|
|
@@ -127,9 +137,7 @@ public class Mounter {
|
|
|
}
|
|
|
} else if (canMountToParent && !canMountToDir) {
|
|
|
MountWithinParentUtil.prepareParentNoMountPoint(userChosenMountPoint);
|
|
|
- cleanup = () -> {
|
|
|
- MountWithinParentUtil.cleanup(userChosenMountPoint);
|
|
|
- };
|
|
|
+ cleanup = () -> MountWithinParentUtil.cleanup(userChosenMountPoint);
|
|
|
}
|
|
|
try {
|
|
|
builder.setMountpoint(userChosenMountPoint);
|
|
@@ -154,6 +162,14 @@ public class Mounter {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void removeCreatedDirectory(Path toDelete) {
|
|
|
+ try {
|
|
|
+ Files.delete(toDelete);
|
|
|
+ } catch (IOException e) {
|
|
|
+ LOG.warn("Unable to remove {} after unmount: {}.", toDelete, e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public MountHandle mount(VaultSettings vaultSettings, Path cryptoFsRoot) throws IOException, MountFailedException {
|
|
|
var mountService = mountProviders.stream().filter(s -> s.getClass().getName().equals(vaultSettings.mountService.getValue())).findFirst().orElse(defaultMountService.getValue());
|
|
|
|