@Override
    public TransferAction action(final Session<?> source, final Session<?> destination, boolean resumeRequested, boolean reloadRequested,
                                 final TransferPrompt prompt, final ListProgressListener listener) throws BackgroundException {
        if(log.isDebugEnabled()) {
            log.debug(String.format("Find transfer action with prompt %s", prompt));
        }
        if(resumeRequested) {
            return TransferAction.comparison;
        }
        final TransferAction action;
        if(reloadRequested) {
            action = TransferAction.forName(
                    PreferencesFactory.get().getProperty("queue.copy.reload.action"));
        }
        else {
            // Use default
            action = TransferAction.forName(
                    PreferencesFactory.get().getProperty("queue.copy.action"));
        }
        if(action.equals(TransferAction.callback)) {
            for(TransferItem upload : roots) {
                final Path copy = mapping.get(upload.remote);
                final Find find = destination.getFeature(Find.class);
                if(find.find(copy)) {
                    // Found remote file
                    if(copy.isDirectory()) {
                        // List files in target directory
                        if(this.list(destination, copy, null, listener).isEmpty()) {
                            // Do not prompt for existing empty directories
                            continue;
                        }
                    }
                    // Prompt user to choose a filter
                    return prompt.prompt(upload);
                }
            }
            // No files exist yet therefore it is most straightforward to use the overwrite action
            return TransferAction.overwrite;
        }
        return action;
    }
@Test
    public void testActionPromptCancel() throws Exception {
        final Path test = new Path("t", EnumSet.of(Path.Type.file));
        final Host target = new Host(new TestProtocol(), "t");
        CopyTransfer t = new CopyTransfer(target,
                target,
                Collections.singletonMap(test, new Path("d", EnumSet.of(Path.Type.file))), new BandwidthThrottle(BandwidthThrottle.UNLIMITED));
        assertEquals(TransferAction.cancel, t.action(new NullTransferSession(target), new NullTransferSession(target), false, true,
                new DisabledTransferPrompt(), new DisabledListProgressListener()));
    }