Skip to content

Commit

Permalink
WinFSP fine tuning. Mounting as network drive has higher priority.
Browse files Browse the repository at this point in the history
  • Loading branch information
overheadhunter committed Nov 6, 2022
1 parent 48fa5de commit 6463f01
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,22 @@
import static org.cryptomator.integrations.mount.MountCapability.READ_ONLY;
import static org.cryptomator.integrations.mount.MountCapability.UNMOUNT_FORCED;

@Priority(100)
@Priority(90)
@OperatingSystem(OperatingSystem.Value.WINDOWS)
public class WinFspMountProvider implements MountService {

private static final String OS_ARCH = System.getProperty("os.arch").toLowerCase();

public WinFspMountProvider() {
}

@Override
public String displayName() {
return "FUSE (WinFsp)";
return "WinFSP";
}

@Override
public boolean isSupported() {
return WinfspUtil.isWinFspInstalled();
}

@Override
public MountBuilder forFileSystem(Path vfsRoot) {
return new WinFspMountBuilder(vfsRoot);
}

@Override
public Set<MountCapability> capabilities() {
return EnumSet.of(MOUNT_FLAGS, MOUNT_AS_DRIVE_LETTER, MOUNT_WITHIN_EXISTING_PARENT, UNMOUNT_FORCED, READ_ONLY);
Expand All @@ -63,6 +55,11 @@ public String getDefaultMountFlags(String mountName) {
return "-ouid=-1 -ogid=-1"; // TODO: research and use correct ones
}

@Override
public MountBuilder forFileSystem(Path vfsRoot) {
return new WinFspMountBuilder(vfsRoot);
}

protected static class WinFspMountBuilder extends AbstractMountBuilder {

boolean isReadOnly = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,24 @@
import static org.cryptomator.integrations.mount.MountCapability.READ_ONLY;
import static org.cryptomator.integrations.mount.MountCapability.UNMOUNT_FORCED;

@Priority(90)
@Priority(100)
@OperatingSystem(OperatingSystem.Value.WINDOWS)
public class WinFspNetworkMountProvider extends WinFspMountProvider {

@Override
public String displayName() {
return "WinFSP (Network Drive)";
}

@Override
public Set<MountCapability> capabilities() {
// no MOUNT_WITHIN_EXISTING_PARENT support here
return EnumSet.of(MOUNT_FLAGS, MOUNT_AS_DRIVE_LETTER, UNMOUNT_FORCED, READ_ONLY);
}

@Override
public String getDefaultMountFlags(String mountName) {
return "-ouid=-1 -ogid=-1 -oVolumePrefix=/localhost/" + mountName; // TODO: instead of /localhost/ we can use any made-up hostname
return super.getDefaultMountFlags(mountName) + " -oVolumePrefix=/localhost/" + mountName; // TODO: instead of /localhost/ we can use any made-up hostname
}

@Override
Expand All @@ -42,9 +48,10 @@ public WinFspNetworkMountBuilder(Path vfsRoot) {
@Override
public MountBuilder setMountpoint(Path mountPoint) {
if (mountPoint.getRoot().equals(mountPoint)) { // MOUNT_AS_DRIVE_LETTER
return super.setMountpoint(mountPoint);
this.mountPoint = mountPoint;
return this;
} else {
throw new IllegalArgumentException("mount point must either be a drive letter or a non-existing node within an existing parent");
throw new IllegalArgumentException("mount point must be a drive letter");
}
}
}
Expand Down

0 comments on commit 6463f01

Please sign in to comment.