@Test public void testSkip() throws Exception { final Path file = new Path("t", EnumSet.of(Path.Type.file)); final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), new NullSession(new Host(new TestProtocol())) { @Override @SuppressWarnings("unchecked") public <T> T _getFeature(final Class<T> type) { if(type == Find.class) { return (T) new Find() { @Override public boolean find(final Path file) { return true; } }; } return super._getFeature(type); } @Override public AttributedList<Path> list(final Path parent, final ListProgressListener listener) { return new AttributedList<Path>(Collections.singletonList(file)); } }); file.attributes().setSize(1L); assertFalse(f.accept(file, new NullLocal("a") { @Override public boolean exists() { return true; } @Override public LocalAttributes attributes() { return new LocalAttributes("t") { @Override public long getSize() { return 1L; } }; } }, new TransferStatus().exists(true))); }
@Override public boolean accept(final Path file, final Local local, final TransferStatus parent) throws BackgroundException { if(super.accept(file, local, parent)) { if(local.isFile()) { if(parent.isExists()) { final Write.Append append = upload.append(file, local.attributes().getSize(), cache); if(append.size == local.attributes().getSize()) { if(Checksum.NONE != append.checksum) { final ChecksumCompute compute = ChecksumComputeFactory.get(append.checksum.algorithm); if(compute.compute(local.getInputStream(), parent).equals(append.checksum)) { if(log.isInfoEnabled()) { log.info(String.format("Skip file %s with checksum %s", file, local.attributes().getChecksum())); } return false; } log.warn(String.format("Checksum mismatch for %s and %s", file, local)); } else { if(log.isInfoEnabled()) { log.info(String.format("Skip file %s with remote size %d", file, append.size)); } return false; } } } } return true; } return false; }
ResumeFilter extends AbstractUploadFilter { @Override public boolean accept(final Path file, final Local local, final TransferStatus parent) throws BackgroundException { if(super.accept(file, local, parent)) { if(local.isFile()) { if(parent.isExists()) { final Write.Append append = upload.append(file, local.attributes().getSize(), cache); if(append.size == local.attributes().getSize()) { if(Checksum.NONE != append.checksum) { final ChecksumCompute compute = ChecksumComputeFactory.get(append.checksum.algorithm); if(compute.compute(local.getInputStream(), parent).equals(append.checksum)) { if(log.isInfoEnabled()) { log.info(String.format("Skip file %s with checksum %s", file, local.attributes().getChecksum())); } return false; } log.warn(String.format("Checksum mismatch for %s and %s", file, local)); } else { if(log.isInfoEnabled()) { log.info(String.format("Skip file %s with remote size %d", file, append.size)); } return false; } } } } return true; } return false; } }
ResumeFilter extends AbstractUploadFilter { @Override public boolean accept(final Path file, final Local local, final TransferStatus parent) throws BackgroundException { if(super.accept(file, local, parent)) { if(local.isFile()) { if(parent.isExists()) { final Write.Append append = upload.append(file, local.attributes().getSize(), cache); if(append.size == local.attributes().getSize()) { if(Checksum.NONE != append.checksum) { final ChecksumCompute compute = ChecksumComputeFactory.get(append.checksum.algorithm); if(compute.compute(local.getInputStream(), parent).equals(append.checksum)) { if(log.isInfoEnabled()) { log.info(String.format("Skip file %s with checksum %s", file, local.attributes().getChecksum())); } return false; } log.warn(String.format("Checksum mismatch for %s and %s", file, local)); } else { if(log.isInfoEnabled()) { log.info(String.format("Skip file %s with remote size %d", file, append.size)); } return false; } } } } return true; } return false; } ResumeFilter(final SymlinkResolver<Local> symlinkResolver, final Session<?> session);  ResumeFilter(final SymlinkResolver<Local> symlinkResolver, final Session<?> session,
                        final UploadFilterOptions options);  ResumeFilter(final SymlinkResolver<Local> symlinkResolver, final Session<?> session,
                        final UploadFilterOptions options, final Upload upload); }
ResumeFilter extends AbstractUploadFilter { @Override public boolean accept(final Path file, final Local local, final TransferStatus parent) throws BackgroundException { if(super.accept(file, local, parent)) { if(local.isFile()) { if(parent.isExists()) { final Write.Append append = upload.append(file, local.attributes().getSize(), cache); if(append.size == local.attributes().getSize()) { if(Checksum.NONE != append.checksum) { final ChecksumCompute compute = ChecksumComputeFactory.get(append.checksum.algorithm); if(compute.compute(local.getInputStream(), parent).equals(append.checksum)) { if(log.isInfoEnabled()) { log.info(String.format("Skip file %s with checksum %s", file, local.attributes().getChecksum())); } return false; } log.warn(String.format("Checksum mismatch for %s and %s", file, local)); } else { if(log.isInfoEnabled()) { log.info(String.format("Skip file %s with remote size %d", file, append.size)); } return false; } } } } return true; } return false; } ResumeFilter(final SymlinkResolver<Local> symlinkResolver, final Session<?> session);  ResumeFilter(final SymlinkResolver<Local> symlinkResolver, final Session<?> session,
                        final UploadFilterOptions options);  ResumeFilter(final SymlinkResolver<Local> symlinkResolver, final Session<?> session,
                        final UploadFilterOptions options, final Upload upload); @Override AbstractUploadFilter withCache(final Cache<Path> cache); @Override boolean accept(final Path file, final Local local, final TransferStatus parent); @Override TransferStatus prepare(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress); }
ResumeFilter extends AbstractUploadFilter { @Override public boolean accept(final Path file, final Local local, final TransferStatus parent) throws BackgroundException { if(super.accept(file, local, parent)) { if(local.isFile()) { if(parent.isExists()) { final Write.Append append = upload.append(file, local.attributes().getSize(), cache); if(append.size == local.attributes().getSize()) { if(Checksum.NONE != append.checksum) { final ChecksumCompute compute = ChecksumComputeFactory.get(append.checksum.algorithm); if(compute.compute(local.getInputStream(), parent).equals(append.checksum)) { if(log.isInfoEnabled()) { log.info(String.format("Skip file %s with checksum %s", file, local.attributes().getChecksum())); } return false; } log.warn(String.format("Checksum mismatch for %s and %s", file, local)); } else { if(log.isInfoEnabled()) { log.info(String.format("Skip file %s with remote size %d", file, append.size)); } return false; } } } } return true; } return false; } ResumeFilter(final SymlinkResolver<Local> symlinkResolver, final Session<?> session);  ResumeFilter(final SymlinkResolver<Local> symlinkResolver, final Session<?> session,
                        final UploadFilterOptions options);  ResumeFilter(final SymlinkResolver<Local> symlinkResolver, final Session<?> session,
                        final UploadFilterOptions options, final Upload upload); @Override AbstractUploadFilter withCache(final Cache<Path> cache); @Override boolean accept(final Path file, final Local local, final TransferStatus parent); @Override TransferStatus prepare(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress);  }