@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { return delegate.list(vault.encrypt(session, directory), new DecryptingListProgressListener(session, vault, listener)); }
@Override public AttributedList<Path> run(final Session<?> session) throws BackgroundException { try { if(this.isCached()) { final AttributedList<Path> list = cache.get(directory); listener.chunk(directory, list); return list; } final ListService service = session.getFeature(ListService.class).withCache(cache); return service.list(directory, listener); } catch(ListCanceledException e) { return e.getChunk(); } }
@Override public ListService withCache(final Cache<Path> cache) { proxy.withCache(cache); return this; }
@Override public ListService withCache(final Cache<Path> cache) { delegate.withCache(cache); return this; } }
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { return delegate.list(directory, new ProxyListProgressListener(finder, listener)); } catch(VaultFoundListCanceledException finder) { final Vault cryptomator = finder.getVault(); if(log.isInfoEnabled()) { log.info(String.format("Found vault %s", cryptomator)); } return delegate.list(cryptomator.encrypt(session, directory), new DecryptingListProgressListener(session, cryptomator, listener.reset())); } }
@Override public ListService withCache(final Cache<Path> cache) { delegate.withCache(new CryptoPathCache(cache)); return this; }
@Override public List<TransferItem> list(final Session<?> session, final Path directory, final Local local, final ListProgressListener listener) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("List children for %s", directory)); } final AttributedList<Path> list = session.getFeature(ListService.class).list(directory, listener).filter(comparator, filter); final Path copy = mapping.get(directory); for(Path p : list) { mapping.put(p, new Path(copy, p.getName(), p.getType(), p.attributes())); } final List<TransferItem> nullified = new ArrayList<TransferItem>(); for(Path p : list) { nullified.add(new TransferItem(p)); } return nullified; }
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final Vault vault = registry.find(session, directory); if(vault.contains(directory)) { return vault.getFeature(session, ListService.class, proxy).list(directory, listener); } if(autodetect) { return new VaultFinderListService(session, proxy, new VaultFinderListProgressListener(lookup)).list(directory, listener); } return proxy.list(directory, listener); } catch(VaultUnlockCancelException e) { log.warn(String.format("Canceled loading vault %s. %s", e.getVault(), e.getDetail())); throw e; } }
return this.post(directory, implementations.get(Command.mlsd).list(directory, listener), listener); return this.post(directory, implementations.get(Command.stat).list(directory, listener), listener); return this.post(directory, implementations.get(Command.lista).list(directory, listener), listener); return this.post(directory, implementations.get(Command.list).list(directory, listener), listener);
@Override public List<TransferItem> list(final Session<?> session, final Path directory, final Local local, final ListProgressListener listener) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("List children for %s", directory)); } if(directory.isSymbolicLink() && new DownloadSymlinkResolver(roots).resolve(directory)) { if(log.isDebugEnabled()) { log.debug(String.format("Do not list children for symbolic link %s", directory)); } return Collections.emptyList(); } else { final AttributedList<Path> list; if(cache.isCached(directory)) { list = cache.get(directory); } else { list = session.getFeature(ListService.class).list(directory, listener); cache.put(directory, list); } final List<TransferItem> children = new ArrayList<TransferItem>(); // Return copy with filtered result only for(Path f : new AttributedList<Path>(list.filter(comparator, filter))) { children.add(new TransferItem(f, LocalFactory.get(local, f.getName()))); } return children; } }
protected void write(final Session<?> session, final Metadata feature, final Path file) throws BackgroundException { if(this.isCanceled()) { throw new ConnectionCanceledException(); } // Read online metadata (storing non-edited metadata entries) final Map<String, String> update = new HashMap<>(file.attributes().getMetadata()); // Purge removed entries update.entrySet().removeIf(entry -> !metadata.containsKey(entry.getKey())); // iterate all metadata entries and for(Map.Entry<String, String> entry : metadata.entrySet()) { // check if update is non-null (should not) && entry value is not null if(entry.getValue() != null) { // update update.put(entry.getKey(), entry.getValue()); } } // If anything has changed save metadata, otherwise continue and do for everything underneath this directory if(!update.equals(file.attributes().getMetadata())) { listener.message(MessageFormat.format(LocaleFactory.localizedString("Writing metadata of {0}", "Status"), file.getName())); feature.setMetadata(file, update); } if(file.isDirectory()) { if(callback.recurse(file, LocaleFactory.localizedString("Metadata", "Info"))) { for(Path child : session.getFeature(ListService.class).list(file, new WorkerListProgressListener(this, listener))) { this.write(session, feature, child); } } } }
final Path dataRoot = new Path(f, "d", f.getType()); if(find.find(dataRoot)) { for(Path d : session._getFeature(ListService.class).list(dataRoot, new DisabledListProgressListener()).toList()) { metadata.addAll(session._getFeature(ListService.class).list(d, new DisabledListProgressListener()).toList()); metadata.add(d); for(Path m : session._getFeature(ListService.class).list(metaRoot, new DisabledListProgressListener()).toList()) { for(Path m2 : session._getFeature(ListService.class).list(m, new DisabledListProgressListener()).toList()) { metadata.addAll(session._getFeature(ListService.class).list(m2, new DisabledListProgressListener()).toList()); metadata.add(m2);
protected void write(final Session<?> session, final UnixPermission feature, final Path file, final Permission permission) throws BackgroundException { listener.message(MessageFormat.format(LocaleFactory.localizedString("Changing permission of {0} to {1}", "Status"), file.getName(), permission)); feature.setUnixPermission(file, permission); if(file.isDirectory()) { if(callback.recurse(file, permission)) { for(Path child : session.getFeature(ListService.class).list(file, new WorkerListProgressListener(this, listener))) { this.write(session, feature, child, permission); } } } }
protected Map<Path, Path> compile(final Move move, final ListService list, final Path source, final Path target) throws BackgroundException { // Compile recursive list final Map<Path, Path> recursive = new LinkedHashMap<>(); recursive.put(source, target); if(source.isDirectory()) { if(!move.isRecursive(source, target)) { // sort ascending by timestamp to move older versions first final AttributedList<Path> children = list.list(source, new WorkerListProgressListener(this, listener)). filter(new TimestampComparator(true)); for(Path child : children) { if(this.isCanceled()) { throw new ConnectionCanceledException(); } recursive.putAll(this.compile(move, list, child, new Path(target, child.getName(), child.getType()))); } } } return recursive; }
@Override public AttributedList<Path> search(final Path workdir, final Filter<Path> filter, final ListProgressListener listener) throws BackgroundException { final AttributedList<Path> list; if(!cache.isCached(workdir)) { list = session.getFeature(ListService.class).list(workdir, new SearchListProgressListener(filter, listener)).filter(filter); } else { list = cache.get(workdir).filter(filter); } listener.chunk(workdir, list); return list; }
protected Map<Path, Path> compile(final Copy copy, final ListService list, final Path source, final Path target) throws BackgroundException { // Compile recursive list final Map<Path, Path> recursive = new LinkedHashMap<>(); if(source.isFile() || source.isSymbolicLink()) { recursive.put(source, target); } else if(source.isDirectory()) { // Add parent before children recursive.put(source, target); if(!copy.isRecursive(source, target)) { // sort ascending by timestamp to copy older versions first final AttributedList<Path> children = list.list(source, new WorkerListProgressListener(this, listener)). filter(new TimestampComparator(true)); for(Path child : children) { if(this.isCanceled()) { throw new ConnectionCanceledException(); } recursive.putAll(this.compile(copy, list, child, new Path(target, child.getName(), child.getType()))); } } } return recursive; }
protected void write(final Session<?> session, final Redundancy feature, final Path file) throws BackgroundException { if(this.isCanceled()) { throw new ConnectionCanceledException(); } if(!level.equals(file.attributes().getStorageClass())) { listener.message(MessageFormat.format(LocaleFactory.localizedString("Writing metadata of {0}", "Status"), file.getName())); feature.setClass(file, level); } if(file.isDirectory()) { if(callback.recurse(file, level)) { for(Path child : session.getFeature(ListService.class).list(file, new WorkerListProgressListener(this, listener))) { this.write(session, feature, child); } } } }
for(Path child : list.list(file, listener).filter(filter)) { if(this.isCanceled()) { throw new ConnectionCanceledException();
protected void write(final Session<?> session, final Encryption feature, final Path file) throws BackgroundException { if(this.isCanceled()) { throw new ConnectionCanceledException(); } listener.message(MessageFormat.format(LocaleFactory.localizedString("Writing metadata of {0}", "Status"), file.getName())); feature.setEncryption(file, algorithm); if(file.isDirectory()) { if(callback.recurse(file, algorithm)) { for(Path child : session.getFeature(ListService.class).list(file, new WorkerListProgressListener(this, listener))) { this.write(session, feature, child); } } } }
protected void write(final Session<?> session, final AclPermission feature, final Path file) throws BackgroundException { if(this.isCanceled()) { throw new ConnectionCanceledException(); } listener.message(MessageFormat.format(LocaleFactory.localizedString("Changing permission of {0} to {1}", "Status"), file.getName(), acl)); feature.setPermission(file, acl); if(file.isVolume()) { // No recursion when changing container ACL } else if(file.isDirectory()) { if(callback.recurse(file, acl)) { for(Path child : session.getFeature(ListService.class).list(file, new WorkerListProgressListener(this, listener))) { this.write(session, feature, child); } } } }