Browse Source

activate ability to abort vault locking if it is mounted with dokany and still busy

references #1228
Armin Schrenk 4 years ago
parent
commit
5d00b3dd76

+ 12 - 4
main/commons/src/main/java/org/cryptomator/common/vaults/DokanyVolume.java

@@ -13,7 +13,6 @@ import org.slf4j.LoggerFactory;
 
 import javax.inject.Inject;
 import javax.inject.Named;
-import java.util.SortedSet;
 import java.util.concurrent.ExecutorService;
 
 public class DokanyVolume extends AbstractVolume {
@@ -42,7 +41,6 @@ public class DokanyVolume extends AbstractVolume {
 	@Override
 	public void mount(CryptoFileSystem fs, String mountFlags) throws InvalidMountPointException, VolumeException {
 		this.mountPoint = determineMountPoint();
-		String mountName = vaultSettings.mountName().get();
 		try {
 			this.mount = mountFactory.mount(fs.getPath("/"), mountPoint, vaultSettings.mountName().get(), FS_TYPE_NAME, mountFlags.strip());
 		} catch (MountFailedException e) {
@@ -62,8 +60,18 @@ public class DokanyVolume extends AbstractVolume {
 	}
 
 	@Override
-	public void unmount() {
-		mount.close();
+	public void unmount() throws VolumeException {
+		try {
+			mount.unmount();
+		} catch (IllegalStateException e) {
+			throw new VolumeException("Unmount Failed.", e);
+		}
+		cleanupMountPoint();
+	}
+
+	@Override
+	public void unmountForced() {
+		mount.close(); //TODO: with next dokany-nio-release, change this to unmountForced()
 		cleanupMountPoint();
 	}