@Test public void testAppendEqualSize() throws Exception { final NullSession session = new NullSession(new Host(new TestProtocol())); final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), session, new UploadFilterOptions().withTemporary(true), new DefaultUploadFeature<Void>(new NullWriteFeature(session)) { @Override public Write.Append append(final Path file, final Long length, final Cache<Path> cache) { return new Write.Append(length); } }); final long size = 3L; final Path t = new Path("t", EnumSet.of(Path.Type.file)); assertFalse(f.accept(t, new NullLocal("t") { @Override public LocalAttributes attributes() { return new LocalAttributes("t") { @Override public long getSize() { return size; } }; } @Override public boolean isFile() { return true; } @Override public boolean exists() { return true; } }, 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);  }