@Override
    public AttributedList<Path> search(final Path workdir, final Filter<Path> regex, final ListProgressListener listener) throws BackgroundException {
        if(workdir.isRoot()) {
            final AttributedList<Path> result = new AttributedList<>();
            final AttributedList<Path> buckets = new GoogleStorageBucketListService(session).list(workdir, listener);
            for(Path bucket : buckets) {
                result.addAll(filter(regex, new GoogleStorageObjectListService(session).list(bucket, listener, null)));
            }
            result.addAll(filter(regex, buckets));
            return result;
        }
        try {
            return filter(regex, new GoogleStorageObjectListService(session).list(workdir, listener, null));
        }
        catch(NotfoundException e) {
            return AttributedList.emptyList();
        }
    }
@Test
    public void testSearchInDirectory() throws Exception {
        final Path bucket = new Path("cyberduck-test-eu", EnumSet.of(Path.Type.directory, Path.Type.volume));
        final String name = new AlphanumericRandomStringService().random();
        final Path file = new GoogleStorageTouchFeature(session).touch(new Path(bucket, name, EnumSet.of(Path.Type.file)), new TransferStatus());
        final GoogleStorageSearchFeature feature = new GoogleStorageSearchFeature(session);
        assertTrue(feature.search(bucket, new SearchFilter(name), new DisabledListProgressListener()).contains(file));
        assertTrue(feature.search(bucket, new SearchFilter(StringUtils.substring(name, 2)), new DisabledListProgressListener()).contains(file));
        {
            final AttributedList<Path> result = feature.search(bucket, new SearchFilter(StringUtils.substring(name, 0, name.length() - 2)), new DisabledListProgressListener());
            assertTrue(result.contains(file));
        }
        assertFalse(feature.search(new Path(bucket, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new SearchFilter(name), new DisabledListProgressListener()).contains(file));
        final Path subdir = new GoogleStorageDirectoryFeature(session).mkdir(new Path(bucket, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
        assertFalse(feature.search(subdir, new SearchFilter(name), new DisabledListProgressListener()).contains(file));
        final Path filesubdir = new GoogleStorageTouchFeature(session).touch(new Path(subdir, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
        {
            final AttributedList<Path> result = feature.search(bucket, new SearchFilter(filesubdir.getName()), new DisabledListProgressListener());
            assertNotNull(result.find(new SimplePathPredicate(filesubdir)));
            assertEquals(subdir, result.find(new SimplePathPredicate(filesubdir)).getParent());
        }
        new GoogleStorageDeleteFeature(session).delete(Arrays.asList(file, filesubdir, subdir), new DisabledLoginCallback(), new Delete.DisabledCallback());
    }