Change volume interface to observe mounts

This commit is contained in:
Armin Schrenk
2021-03-23 12:37:36 +01:00
parent b199b65e38
commit c05e00d32a
4 changed files with 14 additions and 4 deletions

View File

@@ -13,6 +13,8 @@ import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutorService;
public class DokanyVolume extends AbstractVolume {
@@ -39,7 +41,7 @@ public class DokanyVolume extends AbstractVolume {
}
@Override
public void mount(CryptoFileSystem fs, String mountFlags) throws InvalidMountPointException, VolumeException {
public CompletionStage<Void> mount(CryptoFileSystem fs, String mountFlags) throws InvalidMountPointException, VolumeException {
this.mountPoint = determineMountPoint();
try {
this.mount = mountFactory.mount(fs.getPath("/"), mountPoint, vaultSettings.mountName().get(), FS_TYPE_NAME, mountFlags.strip());
@@ -49,6 +51,7 @@ public class DokanyVolume extends AbstractVolume {
}
throw new VolumeException("Unable to mount Filesystem", e);
}
return CompletableFuture.failedFuture(new IllegalStateException("THOU SHOULD NOT PASS")); //FIXME
}
@Override

View File

@@ -20,6 +20,8 @@ import javax.inject.Named;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.regex.Pattern;
public class FuseVolume extends AbstractVolume {
@@ -35,10 +37,11 @@ public class FuseVolume extends AbstractVolume {
}
@Override
public void mount(CryptoFileSystem fs, String mountFlags) throws InvalidMountPointException, VolumeException {
public CompletionStage<Void> mount(CryptoFileSystem fs, String mountFlags) throws InvalidMountPointException, VolumeException {
this.mountPoint = determineMountPoint();
mount(fs.getPath("/"), mountFlags);
return CompletableFuture.failedFuture(new IllegalStateException("THOU SHOULD NOT PASS")); //FIXME
}
private void mount(Path root, String mountFlags) throws VolumeException {

View File

@@ -7,6 +7,7 @@ import org.cryptomator.cryptofs.CryptoFileSystem;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Optional;
import java.util.concurrent.CompletionStage;
import java.util.stream.Stream;
/**
@@ -32,7 +33,7 @@ public interface Volume {
* @param fs
* @throws IOException
*/
void mount(CryptoFileSystem fs, String mountFlags) throws IOException, VolumeException, InvalidMountPointException;
CompletionStage<Void> mount(CryptoFileSystem fs, String mountFlags) throws IOException, VolumeException, InvalidMountPointException;
/**
* Reveals the mounted volume.

View File

@@ -17,6 +17,8 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.file.Path;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.function.Supplier;
public class WebDavVolume implements Volume {
@@ -41,9 +43,10 @@ public class WebDavVolume implements Volume {
}
@Override
public void mount(CryptoFileSystem fs, String mountFlags) throws VolumeException {
public CompletionStage<Void> mount(CryptoFileSystem fs, String mountFlags) throws VolumeException {
startServlet(fs);
mountServlet();
return CompletableFuture.failedFuture(new IllegalStateException("THOU SHOULD NOT PASS")); //FIXME
}
private void startServlet(CryptoFileSystem fs){