@Override public Vault find(final Session session, final Path file) throws VaultUnlockCancelException { return this.find(session, file, true); }
public static VaultRegistry create(final HostPasswordStore keychain, final PasswordCallback callback) { return PreferencesFactory.get().getBoolean("cryptomator.enable") ? new DefaultVaultRegistry(keychain, callback) : VaultRegistry.DISABLED; } }
@Override public boolean isRecursive(final Path source, final Path target) { try { if(registry.find(session, source, false).equals(registry.find(session, target, false))) { return registry.find(session, source, false).getFeature(session, Move.class, proxy).isRecursive(source, target); } return session.getFeature(Copy.class).isRecursive(source, target); } catch(VaultUnlockCancelException e) { return proxy.isRecursive(source, target); } }
@Override public boolean isSupported(final Path source, final Path target) { // Run through registry without looking for vaults to circumvent deadlock due to synchronized load of vault try { if(registry.find(session, source, false).equals(registry.find(session, target, false))) { return registry.find(session, source, false).getFeature(session, Move.class, proxy).isSupported(source, target); } return session.getFeature(Copy.class).isSupported(source, target); } catch(VaultUnlockCancelException e) { return proxy.isSupported(source, target); } }
@Override public Path copy(final Path source, final Path copy, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { if(registry.find(session, source).equals(Vault.DISABLED)) { return registry.find(session, copy).getFeature(session, Copy.class, proxy).withTarget(destination).copy(source, copy, status, callback); } else if(registry.find(session, copy).equals(Vault.DISABLED)) { return registry.find(session, source).getFeature(session, Copy.class, proxy).withTarget(destination).copy(source, copy, status, callback); } else { // Move files inside vault. May use server side copy. return registry.find(session, copy).getFeature(session, Copy.class, proxy).withTarget(destination).copy(source, copy, status, callback); } }
@Override public Path touch(final Path file, final TransferStatus status) throws BackgroundException { return registry.find(session, file).getFeature(session, Touch.class, proxy).touch(file, status); }
@Override public boolean isRecursive(final Path source, final Path copy) { try { if(registry.find(session, source, false).equals(Vault.DISABLED)) { return registry.find(session, copy, false).getFeature(session, Copy.class, proxy).withTarget(destination).isRecursive(source, copy); } else if(registry.find(session, copy, false).equals(Vault.DISABLED)) { return registry.find(session, source, false).getFeature(session, Copy.class, proxy).withTarget(destination).isRecursive(source, copy); } return registry.find(session, copy).getFeature(session, Copy.class, proxy).withTarget(destination).isRecursive(source, copy); } catch(VaultUnlockCancelException e) { return proxy.isRecursive(source, copy); } }
@Override public boolean isSupported(final Path source, final Path copy) { try { if(registry.find(session, source, false).equals(Vault.DISABLED)) { return registry.find(session, copy, false).getFeature(session, Copy.class, proxy).withTarget(destination).isSupported(source, copy); } else if(registry.find(session, copy, false).equals(Vault.DISABLED)) { return registry.find(session, source, false).getFeature(session, Copy.class, proxy).withTarget(destination).isSupported(source, copy); } return registry.find(session, copy).getFeature(session, Copy.class, proxy).withTarget(destination).isSupported(source, copy); } catch(VaultUnlockCancelException e) { return proxy.isSupported(source, copy); } }
@Override public Path move(final Path source, final Path target, final TransferStatus status, final Delete.Callback delete, final ConnectionCallback callback) throws BackgroundException { final Vault vault = registry.find(session, source); if(vault.equals(registry.find(session, target, false))) { if(log.isDebugEnabled()) { log.debug(String.format("Move %s to %s inside vault %s", source, target, vault)); } // Move files inside vault return vault.getFeature(session, Move.class, proxy).move(source, target, status, delete, callback); } else { // Moving files from or into vault requires to pass through encryption features using copy operation final Path copy = session.getFeature(Copy.class).withTarget(destination).copy(source, target, status, callback); // Delete source file after copy is complete session.getFeature(Delete.class).delete(Collections.singletonList(source), callback, delete); return copy; } }
@Override public boolean isSupported(final Path workdir) { // Run through registry without looking for vaults to circumvent deadlock due to synchronized load of vault try { return registry.find(session, workdir, false).getFeature(session, Touch.class, proxy).isSupported(workdir); } catch(VaultUnlockCancelException e) { return proxy.isSupported(workdir); } }
@Override public DescriptiveUrlBag toUrl(final Path file) { try { return registry.find(session, file, false).getFeature(session, UrlProvider.class, proxy).toUrl(file); } catch(VaultUnlockCancelException e) { return proxy.toUrl(file); } }