def patch_fetch_format(options):
    """
    When upload type is fetch, remove the format options.
    In addition, set the fetch_format options to the format value unless it was already set.
    Mutates the options parameter!

    :param options: URL and transformation options
    """
    if options.get('type', 'upload') != 'fetch':
        return
    resource_format = options.pop('format', None)
    if 'fetch_format' not in options:
        options['fetch_format'] = resource_format
