@Test(expected = NotfoundException.class) public void testListNotfound() throws Exception { final LocalSession session = new LocalSession(new Host(new LocalProtocol(), new LocalProtocol().getDefaultHostname())); session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback()); session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback()); final Path f = new Path(UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory)); final LocalListService service = new LocalListService(session); service.list(f, new DisabledListProgressListener()); }
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { final AttributedList<ch.cyberduck.core.Path> paths = new AttributedList<>(); try (DirectoryStream<java.nio.file.Path> directoryStream = Files.newDirectoryStream(session.toPath(directory))) { for(java.nio.file.Path path : directoryStream) { if(null == path.getFileName()) { continue; } try { final PathAttributes attributes = feature.convert(path); final EnumSet<Path.Type> type = EnumSet.noneOf(Path.Type.class); if(Files.isDirectory(path)) { type.add(Path.Type.directory); } else { type.add(Path.Type.file); } final Path file = new Path(directory, path.getFileName().toString(), type, attributes); if(this.post(path, file)) { paths.add(file); listener.chunk(directory, paths); } } catch(IOException e) { log.warn(String.format("Failure reading attributes for %s", path)); } } } catch(IOException ex) { throw new LocalExceptionMappingService().map("Listing directory {0} failed", ex, directory); } return paths; }
LocalListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { final AttributedList<ch.cyberduck.core.Path> paths = new AttributedList<>(); try (DirectoryStream<java.nio.file.Path> directoryStream = Files.newDirectoryStream(session.toPath(directory))) { for(java.nio.file.Path path : directoryStream) { if(null == path.getFileName()) { continue; } try { final PathAttributes attributes = feature.convert(path); final EnumSet<Path.Type> type = EnumSet.noneOf(Path.Type.class); if(Files.isDirectory(path)) { type.add(Path.Type.directory); } else { type.add(Path.Type.file); } final Path file = new Path(directory, path.getFileName().toString(), type, attributes); if(this.post(path, file)) { paths.add(file); listener.chunk(directory, paths); } } catch(IOException e) { log.warn(String.format("Failure reading attributes for %s", path)); } } } catch(IOException ex) { throw new LocalExceptionMappingService().map("Listing directory {0} failed", ex, directory); } return paths; } }
LocalListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { final AttributedList<ch.cyberduck.core.Path> paths = new AttributedList<>(); try (DirectoryStream<java.nio.file.Path> directoryStream = Files.newDirectoryStream(session.toPath(directory))) { for(java.nio.file.Path path : directoryStream) { if(null == path.getFileName()) { continue; } try { final PathAttributes attributes = feature.convert(path); final EnumSet<Path.Type> type = EnumSet.noneOf(Path.Type.class); if(Files.isDirectory(path)) { type.add(Path.Type.directory); } else { type.add(Path.Type.file); } final Path file = new Path(directory, path.getFileName().toString(), type, attributes); if(this.post(path, file)) { paths.add(file); listener.chunk(directory, paths); } } catch(IOException e) { log.warn(String.format("Failure reading attributes for %s", path)); } } } catch(IOException ex) { throw new LocalExceptionMappingService().map("Listing directory {0} failed", ex, directory); } return paths; } LocalListService(final LocalSession session); }
LocalListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { final AttributedList<ch.cyberduck.core.Path> paths = new AttributedList<>(); try (DirectoryStream<java.nio.file.Path> directoryStream = Files.newDirectoryStream(session.toPath(directory))) { for(java.nio.file.Path path : directoryStream) { if(null == path.getFileName()) { continue; } try { final PathAttributes attributes = feature.convert(path); final EnumSet<Path.Type> type = EnumSet.noneOf(Path.Type.class); if(Files.isDirectory(path)) { type.add(Path.Type.directory); } else { type.add(Path.Type.file); } final Path file = new Path(directory, path.getFileName().toString(), type, attributes); if(this.post(path, file)) { paths.add(file); listener.chunk(directory, paths); } } catch(IOException e) { log.warn(String.format("Failure reading attributes for %s", path)); } } } catch(IOException ex) { throw new LocalExceptionMappingService().map("Listing directory {0} failed", ex, directory); } return paths; } LocalListService(final LocalSession session); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener); }
LocalListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { final AttributedList<ch.cyberduck.core.Path> paths = new AttributedList<>(); try (DirectoryStream<java.nio.file.Path> directoryStream = Files.newDirectoryStream(session.toPath(directory))) { for(java.nio.file.Path path : directoryStream) { if(null == path.getFileName()) { continue; } try { final PathAttributes attributes = feature.convert(path); final EnumSet<Path.Type> type = EnumSet.noneOf(Path.Type.class); if(Files.isDirectory(path)) { type.add(Path.Type.directory); } else { type.add(Path.Type.file); } final Path file = new Path(directory, path.getFileName().toString(), type, attributes); if(this.post(path, file)) { paths.add(file); listener.chunk(directory, paths); } } catch(IOException e) { log.warn(String.format("Failure reading attributes for %s", path)); } } } catch(IOException ex) { throw new LocalExceptionMappingService().map("Listing directory {0} failed", ex, directory); } return paths; } LocalListService(final LocalSession session); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener);  }