@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("Children for %s", directory));
        }
        final Set<TransferItem> children = new HashSet<>();
        final Find finder = new CachingFindFeature(session, cache, session.getFeature(Find.class, new DefaultFindFeature(session)));
        if(finder.find(directory)) {
            children.addAll(download.list(session, directory, local, listener));
        }
        if(local.exists()) {
            children.addAll(upload.list(session, directory, local, listener));
        }
        return new ArrayList<>(children);
    }
@Test
    public void testChildrenRemoteAndLocalExist() throws Exception {
        final NullLocal directory = new NullLocal(System.getProperty("java.io.tmpdir"), "t") {
            @Override
            public AttributedList<Local> list() {
                final AttributedList<Local> list = new AttributedList<>();
                list.add(new NullLocal(this, "a"));
                return list;
            }
        };
        final Path root = new Path("t", EnumSet.of(Path.Type.directory));
        final Path remote = new Path(root, "a", EnumSet.of(Path.Type.file));
        final NullSession session = new NullSession(new Host(new TestProtocol())) {
            @Override
            public AttributedList<Path> list(final Path file, final ListProgressListener listener) {
                final AttributedList<Path> list = new AttributedList<>();
                if(file.equals(root.getParent())) {
                    list.add(root);
                }
                else {
                    list.add(remote);
                }
                return list;
            }
        };
        new DefaultLocalDirectoryFeature().mkdir(directory);
        Transfer t = new SyncTransfer(new Host(new TestProtocol()), new TransferItem(root, directory));
        final List<TransferItem> list = t.list(session, root, directory, new DisabledListProgressListener());
        assertEquals(1, list.size());
    }