@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()) {
            final Write.Append append = upload.append(file, status);
            if(append.append && append.offset <= status.getLength()) {
                // Append to existing file
                status.withRename((Path) null).withDisplayname((Path) null).setAppend(true);
                status.setLength(status.getLength() - append.offset);
                status.setOffset(append.offset);
                if(log.isDebugEnabled()) {
                    log.debug(String.format("Resume file %s at offset %d and remaining length %d", file, status.getOffset(), status.getLength()));
                }
            }
        }
        return status;
    }
@Test
    public void testPrepareAppend() throws Exception {
        final Host host = new Host(new TestProtocol());
        final ResumeFilter f = new ResumeFilter(new DisabledUploadSymlinkResolver(), new NullSession(host) {
            @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<>(Collections.singletonList(f));
            }
        }, new UploadFilterOptions(host).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());
        assertTrue(status.isExists());
        // Temporary target
        assertNull(status.getRename().remote);
        assertEquals(7L, status.getOffset());
    }