mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-08-29 04:07:23 +00:00
- separated crypto filesystem and nameshortening filesystem for easier invariant testing
- creation of crypto filesystem only via DI in all integration tests (package-private constructor) - new Maven module "filesystem-crypto-integration-tests" for tests as well as to provide a ready-to-use Dagger Component for integration tests in other modules.
This commit is contained in:
@@ -15,7 +15,7 @@ import java.util.concurrent.Executors;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.cryptomator.filesystem.crypto.CryptoFileSystemModule;
|
||||
import org.cryptomator.crypto.engine.impl.CryptoEngineModule;
|
||||
import org.cryptomator.frontend.FrontendFactory;
|
||||
import org.cryptomator.frontend.webdav.WebDavServer;
|
||||
import org.cryptomator.frontend.webdav.mount.WebDavMounter;
|
||||
@@ -33,7 +33,7 @@ import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import javafx.application.Application;
|
||||
|
||||
@Module(includes = CryptoFileSystemModule.class)
|
||||
@Module(includes = CryptoEngineModule.class)
|
||||
class CryptomatorModule {
|
||||
|
||||
private final Application application;
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.cryptomator.filesystem.FileSystem;
|
||||
import org.cryptomator.filesystem.crypto.CryptoFileSystemDelegate;
|
||||
import org.cryptomator.filesystem.crypto.CryptoFileSystemFactory;
|
||||
import org.cryptomator.filesystem.nio.NioFileSystem;
|
||||
import org.cryptomator.filesystem.shortening.ShorteningFileSystemFactory;
|
||||
import org.cryptomator.filesystem.stats.StatsFileSystem;
|
||||
import org.cryptomator.frontend.CommandFailedException;
|
||||
import org.cryptomator.frontend.Frontend;
|
||||
@@ -59,6 +60,7 @@ public class Vault implements Serializable, CryptoFileSystemDelegate {
|
||||
private final Path path;
|
||||
private final Lazy<FrontendFactory> frontendFactory;
|
||||
private final DeferredCloser closer;
|
||||
private final ShorteningFileSystemFactory shorteningFileSystemFactory;
|
||||
private final CryptoFileSystemFactory cryptoFileSystemFactory;
|
||||
private final ObjectProperty<Boolean> unlocked = new SimpleObjectProperty<Boolean>(this, "unlocked", Boolean.FALSE);
|
||||
private final ObservableList<String> namesOfResourcesWithInvalidMac = FXThreads.observableListOnMainThread(FXCollections.observableArrayList());
|
||||
@@ -72,10 +74,11 @@ public class Vault implements Serializable, CryptoFileSystemDelegate {
|
||||
/**
|
||||
* Package private constructor, use {@link VaultFactory}.
|
||||
*/
|
||||
Vault(Path vaultDirectoryPath, Lazy<FrontendFactory> frontendFactory, CryptoFileSystemFactory cryptoFileSystemFactory, DeferredCloser closer) {
|
||||
Vault(Path vaultDirectoryPath, Lazy<FrontendFactory> frontendFactory, ShorteningFileSystemFactory shorteningFileSystemFactory, CryptoFileSystemFactory cryptoFileSystemFactory, DeferredCloser closer) {
|
||||
this.path = vaultDirectoryPath;
|
||||
this.frontendFactory = frontendFactory;
|
||||
this.closer = closer;
|
||||
this.shorteningFileSystemFactory = shorteningFileSystemFactory;
|
||||
this.cryptoFileSystemFactory = cryptoFileSystemFactory;
|
||||
|
||||
try {
|
||||
@@ -114,7 +117,8 @@ public class Vault implements Serializable, CryptoFileSystemDelegate {
|
||||
public synchronized void activateFrontend(CharSequence passphrase) throws FrontendCreationFailedException {
|
||||
try {
|
||||
FileSystem fs = NioFileSystem.rootedAt(path);
|
||||
FileSystem cryptoFs = cryptoFileSystemFactory.unlockExisting(fs, passphrase, this);
|
||||
FileSystem shorteningFs = shorteningFileSystemFactory.get(fs);
|
||||
FileSystem cryptoFs = cryptoFileSystemFactory.unlockExisting(shorteningFs, passphrase, this);
|
||||
StatsFileSystem statsFs = new StatsFileSystem(cryptoFs);
|
||||
statsFileSystem = Optional.of(statsFs);
|
||||
String contextPath = StringUtils.prependIfMissing(mountName, "/");
|
||||
|
||||
@@ -14,6 +14,7 @@ import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.cryptomator.filesystem.crypto.CryptoFileSystemFactory;
|
||||
import org.cryptomator.filesystem.shortening.ShorteningFileSystemFactory;
|
||||
import org.cryptomator.frontend.FrontendFactory;
|
||||
import org.cryptomator.frontend.webdav.mount.WebDavMounter;
|
||||
import org.cryptomator.ui.util.DeferredCloser;
|
||||
@@ -24,18 +25,20 @@ import dagger.Lazy;
|
||||
public class VaultFactory {
|
||||
|
||||
private final Lazy<FrontendFactory> frontendFactory;
|
||||
private final ShorteningFileSystemFactory shorteningFileSystemFactory;
|
||||
private final CryptoFileSystemFactory cryptoFileSystemFactory;
|
||||
private final DeferredCloser closer;
|
||||
|
||||
@Inject
|
||||
public VaultFactory(Lazy<FrontendFactory> frontendFactory, CryptoFileSystemFactory cryptoFileSystemFactory, WebDavMounter mounter, DeferredCloser closer) {
|
||||
public VaultFactory(Lazy<FrontendFactory> frontendFactory, ShorteningFileSystemFactory shorteningFileSystemFactory, CryptoFileSystemFactory cryptoFileSystemFactory, WebDavMounter mounter, DeferredCloser closer) {
|
||||
this.frontendFactory = frontendFactory;
|
||||
this.shorteningFileSystemFactory = shorteningFileSystemFactory;
|
||||
this.cryptoFileSystemFactory = cryptoFileSystemFactory;
|
||||
this.closer = closer;
|
||||
}
|
||||
|
||||
public Vault createVault(Path path) {
|
||||
return new Vault(path, frontendFactory, cryptoFileSystemFactory, closer);
|
||||
return new Vault(path, frontendFactory, shorteningFileSystemFactory, cryptoFileSystemFactory, closer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user