docs: def sync_headers(cloud_obj, headers=None, header_patterns=HEADER_PATTERNS):
      """
      Overwrites the given cloud_obj's headers with the ones given as ``headers`
      and adds additional headers as defined in the HEADERS setting depending on
      the cloud_obj's file name.
      """
      if headers is None:
          headers = {}
  
      # don't set headers on directories
      content_type = getattr(cloud_obj, "content_type", None)
      if content_type == "application/directory":
          return
      matched_headers = {}
      for pattern, pattern_headers in header_patterns:
          if pattern.match(cloud_obj.name):
              matched_headers.update(pattern_headers.copy())
      # preserve headers already set
      matched_headers.update(cloud_obj.headers)
      # explicitly set headers overwrite matches and already set headers
      matched_headers.update(headers)
      if matched_headers != cloud_obj.headers:
          cloud_obj.headers = matched_headers
          cloud_obj.sync_metadata()