@Test public void testPrepare() throws Exception { final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), new NullSession(new Host(new TestProtocol())) { @Override public AttributedList<Path> list(final Path file, final ListProgressListener listener) { final Path f = new Path("t", EnumSet.of(Path.Type.file)); f.attributes().setSize(7L); return new AttributedList<Path>(Collections.<Path>singletonList(f)); } @Override @SuppressWarnings("unchecked") public <T> T _getFeature(Class<T> type) { if(type == AttributesFinder.class) { return (T) new DefaultAttributesFinderFeature(this); } return super._getFeature(type); } }, new UploadFilterOptions().withTemporary(true)); final Path t = new Path("t", EnumSet.of(Path.Type.file)); final TransferStatus status = f.prepare(t, new NullLocal("t") { @Override public LocalAttributes attributes() { return new LocalAttributes("t") { @Override public long getSize() { return 8L; } }; } @Override public boolean isFile() { return true; } }, new TransferStatus().exists(true), new DisabledProgressListener()); assertTrue(status.isAppend()); assertNull(status.getRename().remote); assertEquals(7L, status.getOffset()); }
@Override public TransferStatus prepare(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) throws BackgroundException { final TransferStatus status = super.prepare(file, local, parent, progress); if(file.isFile()) { if(parent.isExists()) { final Write.Append append = upload.append(file, status.getLength(), cache); if(append.append && append.size < local.attributes().getSize()) { status.setAppend(true); status.setLength(status.getLength() - append.size); status.setOffset(append.size); status.rename((Path) null); } } } return status; }
ResumeFilter extends AbstractUploadFilter { @Override public TransferStatus prepare(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) throws BackgroundException { final TransferStatus status = super.prepare(file, local, parent, progress); if(file.isFile()) { if(parent.isExists()) { final Write.Append append = upload.append(file, status.getLength(), cache); if(append.append && append.size < local.attributes().getSize()) { status.setAppend(true); status.setLength(status.getLength() - append.size); status.setOffset(append.size); status.rename((Path) null); } } } return status; } }
ResumeFilter extends AbstractUploadFilter { @Override public TransferStatus prepare(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) throws BackgroundException { final TransferStatus status = super.prepare(file, local, parent, progress); if(file.isFile()) { if(parent.isExists()) { final Write.Append append = upload.append(file, status.getLength(), cache); if(append.append && append.size < local.attributes().getSize()) { status.setAppend(true); status.setLength(status.getLength() - append.size); status.setOffset(append.size); status.rename((Path) null); } } } return status; } 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 TransferStatus prepare(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) throws BackgroundException { final TransferStatus status = super.prepare(file, local, parent, progress); if(file.isFile()) { if(parent.isExists()) { final Write.Append append = upload.append(file, status.getLength(), cache); if(append.append && append.size < local.attributes().getSize()) { status.setAppend(true); status.setLength(status.getLength() - append.size); status.setOffset(append.size); status.rename((Path) null); } } } return status; } 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 TransferStatus prepare(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) throws BackgroundException { final TransferStatus status = super.prepare(file, local, parent, progress); if(file.isFile()) { if(parent.isExists()) { final Write.Append append = upload.append(file, status.getLength(), cache); if(append.append && append.size < local.attributes().getSize()) { status.setAppend(true); status.setLength(status.getLength() - append.size); status.setOffset(append.size); status.rename((Path) null); } } } return status; } 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);  }