@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 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 Path transfer(final Session<?> session, final Session<?> destination, final Path source, final Local n, final TransferOptions options, final TransferStatus status, final ConnectionCallback connectionCallback, final PasswordCallback passwordCallback, final ProgressListener listener, final StreamListener streamListener) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("Transfer file %s with options %s", source, options)); } listener.message(MessageFormat.format(LocaleFactory.localizedString("Copying {0} to {1}", "Status"), source.getName(), mapping.get(source).getName())); if(source.isDirectory()) { if(!status.isExists()) { final Directory feature = destination.getFeature(Directory.class); feature.mkdir(mapping.get(source), null, status); status.setComplete(); } } else { // Transfer final Copy feature = new DefaultCopyFeature(session).withTarget(destination); feature.copy(source, mapping.get(source), status, connectionCallback); this.addTransferred(status.getLength()); } return source; }
.exists(session.getFeature(Find.class, new DefaultFindFeature(session)).withCache(cache).find(r.getValue())) .length(r.getKey().attributes().getSize()); result.put(r.getKey(), copy.copy(r.getKey(), r.getValue(), status, callback));
@Override public Path move(final Path source, final Path target, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException { if(containerService.isContainer(source)) { if(new SimplePathPredicate(source.getParent()).test(target.getParent())) { // Rename only return proxy.move(source, target, status, callback, connectionCallback); } } if(nodeid.isEncrypted(source) ^ nodeid.isEncrypted(target)) { // Moving into or from an encrypted room final Copy copy = session.getFeature(Copy.class); if(log.isDebugEnabled()) { log.debug(String.format("Move %s to %s using copy feature %s", source, target, copy)); } final Path c = copy.copy(source, target, status, connectionCallback); // Delete source file after copy is complete final Delete delete = session.getFeature(Delete.class); if(delete.isSupported(source)) { delete.delete(Collections.singletonList(source), connectionCallback, callback); } return c; } else { return proxy.move(source, target, status, callback, connectionCallback); } }
@Override public Path copy(final Path source, final Path copy, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { if(vault.contains(copy)) { // Write header to be reused in writer final Cryptor cryptor = vault.getCryptor(); final FileHeader header = cryptor.fileHeaderCryptor().create(); status.setHeader(cryptor.fileHeaderCryptor().encryptHeader(header)); status.setNonces(new RandomNonceGenerator()); } if(vault.contains(source) && vault.contains(copy)) { return vault.decrypt(session, proxy.withTarget(target).copy( vault.contains(source) ? vault.encrypt(session, source) : source, vault.contains(copy) ? vault.encrypt(session, copy) : copy, status, callback)); } else { // Copy files from or into vault requires to pass through encryption features final Path target = new DefaultCopyFeature(session).withTarget(this.target).copy( vault.contains(source) ? vault.encrypt(session, source) : source, vault.contains(copy) ? vault.encrypt(session, copy) : copy, status, callback); if(vault.contains(copy)) { return vault.decrypt(session, target); } return target; } }