protected AttributedList<TransferItem> get(final TransferItem directory) { // Return list with filtered files included return cache.get(directory); }
@Override public AttributedList<T> get(final T parent) { return proxy.get(parent); }
public AttributedList<Path> get(final Path directory) { if(!filtered.containsKey(directory)) { filtered.put(directory, cache.get(directory).filter(controller.getComparator(), controller.getFilter())); } return filtered.get(directory); }
/** * Lookup a path by reference in the cache. * * @param reference A child object of a cached directory listing in the cache * @return Null if the path is not in the cache * @see ch.cyberduck.core.AttributedList#get(Referenceable) */ public T lookup(final CacheReference reference) { final T parent = reverse.get(reference); final AttributedList<T> list = proxy.get(parent); if(list.isEmpty()) { log.warn(String.format("Lookup failed for %s in reverse cache", reference)); return null; } final T[] entries = list.toArray(); for(T entry : entries) { if(proxy.key(entry).equals(reference)) { return entry; } } log.warn(String.format("Lookup failed for %s in reverse cache", reference)); return null; }
@Override public boolean validate() { if(StringUtils.contains(inputField.stringValue(), Path.DELIMITER)) { return false; } if(StringUtils.isNotBlank(inputField.stringValue())) { if(cache.get(workdir).contains(new Path(workdir, inputField.stringValue(), EnumSet.of(Path.Type.file)))) { return false; } if(cache.get(workdir).contains(new Path(workdir, inputField.stringValue(), EnumSet.of(Path.Type.directory)))) { return false; } return true; } return false; }
@Override public NSInteger numberOfItemsInComboBox(NSComboBox combo) { return new NSInteger(cache.get(workdir).filter(comparator, filter).size()); }
for(iter = selected.iterator(); iter.hasNext(); ) { final Path item = iter.next(); if(cache.get(item.getParent()).contains(item)) { if(i < 10) { alertText.append("\n").append(Character.toString('\u2022')).append(" ").append(item.getName());
@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; } }
@Override public NSObject comboBox_objectValueForItemAtIndex(final NSComboBox sender, final NSInteger row) { return NSString.stringWithString(cache.get(workdir) .filter(comparator, filter).get(row.intValue()).getName()); } }
@Override public AttributedList<Path> get(final Path folder) { final AttributedList<Path> decrypted = delegate.get(this.toDecrypted(folder)); final AttributedList<Path> list = new AttributedList<>(); // Swap with encrypted paths for(int i = 0; i < decrypted.size(); i++) { final Path f = decrypted.get(i); list.add(i, this.toEncrypted(f)); } return list; }
@Override public Map<TransferItem, TransferStatus> run(final Session<?> session) throws BackgroundException { final Map<TransferItem, TransferStatus> status = new HashMap<TransferItem, TransferStatus>(); for(TransferItem file : transfer.getRoots()) { if(this.isCanceled()) { throw new ConnectionCanceledException(); } status.put(file.getParent(), new TransferStatus().exists(true)); } final TransferPathFilter filter = transfer.filter(session, session, action, listener); if(log.isDebugEnabled()) { log.debug(String.format("Filter cache %s with filter %s", cache, filter)); } for(TransferItem key : cache.keySet()) { if(this.isCanceled()) { throw new ConnectionCanceledException(); } final AttributedList<TransferItem> list = cache.get(key); for(TransferItem file : list) { if(this.isCanceled()) { throw new ConnectionCanceledException(); } final boolean accept = filter.accept(file.remote, file.local, status.get(file.getParent())); status.put(file, filter.prepare(file.remote, file.local, status.get(file.getParent()), listener) .reject(!accept)); } } return status; }
@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 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; }
final AttributedList<Path> list = cache.get(container.getParent()); final Path found = list.find(new SimplePathPredicate(container)); if(null != found) {
final AttributedList<Path> list = cache.get(file.getParent()); final Path found = list.find(new SimplePathPredicate(file)); if(null != found) {
log.warn(String.format("Missing entry for %s in cache", item)); for(TransferItem f : cache.get(item)) {
protected Path search(final Path file) throws BackgroundException { final AttributedList<Path> list; if(!cache.isCached(file.getParent())) { // Do not decrypt filenames to match with input list = session._getFeature(ListService.class).list(file.getParent(), new CachingListProgressListener(cache)); } else { list = cache.get(file.getParent()); } // Search with specific version and region final Path path = list.find(new DefaultPathPredicate(file)); if(path != null) { return path; } // Try to match path only as the version might have changed in the meantime return list.find(session.getCase() == Session.Case.insensitive ? new CaseInsensitivePathPredicate(file) : new SimplePathPredicate(file)); }
@Override public String getFileid(final Path file, final ListProgressListener listener) throws BackgroundException { if(StringUtils.isNotBlank(file.attributes().getVersionId())) { return file.attributes().getVersionId(); } if(cache.isCached(file.getParent())) { final AttributedList<Path> list = cache.get(file.getParent()); final Path found = list.find(new SimplePathPredicate(file)); if(null != found) { if(StringUtils.isNotBlank(found.attributes().getVersionId())) { return this.set(file, found.attributes().getVersionId()); } } } final AttributedList<Path> list = session._getFeature(ListService.class).list(file.getParent(), listener); final Path found = list.find(new SimplePathPredicate(file)); if(null == found) { throw new NotfoundException(file.getAbsolute()); } return this.set(file, found.attributes().getVersionId()); }
final AttributedList<Path> list = cache.get(file.getParent()); final Path found = list.find(new IgnoreTrashedPathPredicate(file)); if(null != found) {