private void cleanupFolder() {
        final List<ContentStorage.FileInformation> files = ContentStorage.get().list(downloader.targetFolder.getFolder(), false, false);

        final Uri companionFile = downloader.useCompanionFiles ? CompanionFileUtils.companionFileExists(files, filename) : null;
        if (companionFile != null) {
            ContentStorage.get().delete(companionFile);
        }

        // check for files in different capitalizations
        final String filenameNormalized = normalized(filename);
        for (ContentStorage.FileInformation fi : files) {
            final String fiNormalized = normalized(fi.name);
            if (fiNormalized.equals(filenameNormalized)) {
                ContentStorage.get().delete(fi.uri);
                // also check companion file for this
                final Uri cf = downloader.useCompanionFiles ? CompanionFileUtils.companionFileExists(files, fi.name) : null;
                if (cf != null) {
                    ContentStorage.get().delete(cf);
                }
            }
        }
    }
check whether the target file or its companion file already exist, and delete both, if so
main/src/main/java/cgeo/geocaching/downloader/ReceiveDownload.java