@Override
    public PathAttributes find(final Path file, final ListProgressListener listener) throws BackgroundException {
        try {
            final FileEntity entity = new FilesApi(new BrickApiClient(session))
                    .download(StringUtils.removeStart(file.getAbsolute(), String.valueOf(Path.DELIMITER)),
                            "stat", null, false, false);
            switch(entity.getType()) {
                case "file":
                    if(file.isDirectory()) {
                        throw new NotfoundException(file.getAbsolute());
                    }
                    break;
                case "directory":
                    if(file.isFile()) {
                        throw new NotfoundException(file.getAbsolute());
                    }
            }
            return this.toAttributes(entity);
        }
        catch(ApiException e) {
            throw new BrickExceptionMappingService().map("Failure to read attributes of {0}", e, file);
        }
    }
@Test
    public void testFindFile() throws Exception {
        final BrickAttributesFinderFeature f = new BrickAttributesFinderFeature(session);
        final Path root = new Path("/", EnumSet.of(Path.Type.volume, Path.Type.directory));
        final PathAttributes rootAttributes = f.find(root);
        final Path folder = new BrickDirectoryFeature(session).mkdir(
                new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
        final long folderTimestamp = f.find(folder).getModificationDate();
        final Path test = new BrickTouchFeature(session).touch(new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)),
                new TransferStatus().withModified(1719480508000L));
        assertEquals(Protocol.DirectoryTimestamp.explicit, session.getHost().getProtocol().getDirectoryTimestamp());
        assertNotEquals(folderTimestamp, f.find(folder).getModificationDate());
        assertEquals(rootAttributes, f.find(root));
        assertEquals(rootAttributes.getModificationDate(), f.find(root).getModificationDate());
        final PathAttributes attributes = f.find(test);
        assertEquals(0L, attributes.getSize());
        assertNotEquals(-1L, attributes.getModificationDate());
        assertTrue(attributes.getPermission().isReadable());
        assertTrue(attributes.getPermission().isWritable());
        // Test wrong type
        try {
            f.find(new Path(test.getAbsolute(), EnumSet.of(Path.Type.directory)));
            fail();
        }
        catch(NotfoundException e) {
            // Expected
        }
        new BrickDeleteFeature(session).delete(Collections.singletonList(folder), new DisabledLoginCallback(), new Delete.DisabledCallback());
    }