public FolderProcessResult synchronizeFolder(final Folder source, final File target, final Predicate<ContentStorage.FileInformation> sourceFilter, final AtomicBoolean cancelFlag, final Consumer<FolderProcessStatus> statusListener) {

        sendCopyStatus(statusListener, null, 0, 0, null);

        final FolderInfo sourceFolderInfo = getFolderInfo(source, -1);
        final ImmutablePair<Integer, Integer> sourceInfo = new ImmutablePair<>(sourceFolderInfo.fileCount, sourceFolderInfo.dirCount);
        sendCopyStatus(statusListener, null, 0, 0, sourceInfo);

        final List<ImmutablePair<ContentStorage.FileInformation, String>> sourceList = getAllFiles(source, sourceFilter);
        final List<ImmutablePair<ContentStorage.FileInformation, String>> targetList = getAllFiles(Folder.fromFile(target));

        final Set<String> targetFilesToDelete = CollectionStream.of(targetList)
                .filter(e -> !e.left.isDirectory && !e.right.endsWith("/" + FOLDER_SYNC_INFO_FILENAME))
                .map(e -> e.right).toSet();
        final Set<String> targetSyncPropsToUpdate = new HashSet<>();

        final Map<String, Properties> targetSyncProps = getTargetFolderSyncProperties(target, targetList);

        //Array stores values for: filesProcessed, filesModified, dirsProcessed, dirsModified
        final int[] processStates = new int[]{0, 0, 0, 0};
        final ContentStorage.FileInformation failedFile = synchronizeFolderProcessAllFiles(target, cancelFlag, statusListener, sourceInfo, sourceList, targetFilesToDelete, targetSyncPropsToUpdate, targetSyncProps, processStates);
        if (failedFile != null) {
            return createFolderProcessResult(ProcessResult.FAILURE, failedFile, processStates[1], processStates[3], sourceInfo);
        }

        //create/update directory sync files
        try {
            synchronizeFolderUpdateSyncFiles(target, cancelFlag, targetSyncPropsToUpdate, targetSyncProps);
        } catch (IOException ioe) {
            return createFolderProcessResult(ProcessResult.FAILURE, null, processStates[1], processStates[3], sourceInfo);
        }

        if (isCancelled(cancelFlag)) {
            return createFolderProcessResult(ProcessResult.ABORTED, null, 0, 0, sourceInfo);
        }

        //delete leftover target files (no longer synced)
        boolean deleteSuccess = true;
        for (String targetFileToDelete : targetFilesToDelete) {
            deleteSuccess &= new File(target, targetFileToDelete).delete();
            processStates[1]++;
        }
        sendCopyStatus(statusListener, null, processStates[0], processStates[2], sourceInfo);

        return createFolderProcessResult(deleteSuccess ? ProcessResult.OK : ProcessResult.FAILURE, null, processStates[1], processStates[3], sourceInfo);
    }
Synchronizes the content of a given folder to a File folder.
<br>
Methods attempts to create a copy of source folder into target folder with as few actual copy approaches as possible.
To achieve this, in target folder (and subfolders) an information file with name {@link #FOLDER_SYNC_INFO_FILENAME}
is maintained. This (property) file contains for each contained file a token with state of source file on last copying.
Currently this contains "lastMofidied" as well as "size" of source file.
Files in target which are not also in source will be deleted on sync.
<br>
Only files are synchronized. Necessary (sub)folder in target are created on need but not explicitely maintained.
<br>
This implementation does NOT support overlapping source and target folders. If such parameters
are given, then behaviour is undefined.

@param source         source for synchronization
@param target         target for synchronization
@param cancelFlag     optional. If not null and flag is set to true during sync, then running process is aborted. Will result in a Result ABORTED to be returned.*
@param statusListener callback for status information, useable to implement GUI progress bar. See {@link #copyAll(Folder, Folder, boolean)} for details.
@return result of synchroioozation attempt
main/src/main/java/cgeo/geocaching/storage/FolderUtils.java