docs: def delete_orphaned_files(modeladmin, request, queryset=None):
      """
      Deletes orphaned files, i.e. media files existing in storage that are not in the database.
      """
      
      execute = request.POST.get('execute')
      
      storage = get_media_storage()
      broken_node_links = []
      orphaned_files_choices = []
  
      broken_nodes, orphaned_files = get_broken_media()
  
      for node in broken_nodes:
          link = mark_safe('<a href="%s">%s</a>' % (node.get_admin_url(), node.__unicode__()))
          broken_node_links.append(link)
  
      for storage_name in orphaned_files:
          file_path = storage.path(storage_name)
          link = mark_safe('<a href="%s">%s</a>' % (
              storage.url(storage_name), file_path))
          orphaned_files_choices.append((storage_name, link))
  
      if not len(orphaned_files_choices) and not len(broken_node_links):
          messages.success(request, message=_('There are no orphaned files.'))
          return HttpResponseRedirect('')
  
      if execute:
          form = DeleteOrphanedFilesForm(queryset, orphaned_files_choices, request.POST)
          if form.is_valid():
              form.save()
              node = FileNode.get_top_node()
              messages.success(request, message=ungettext('Deleted %i file from storage.', 'Deleted %i files from storage.', len(form.success_files)) % len(form.success_files))
              if form.error_files:
                  messages.error(request, message=_('The following files could not be deleted from storage:')+' '+repr(form.error_files))
              return HttpResponseRedirect(node.get_admin_url())
  
      if not execute:
          if len(orphaned_files_choices) > 0:
              form = DeleteOrphanedFilesForm(queryset, orphaned_files_choices)
          else:
              form = None
  
      c = get_actions_context(modeladmin)
      c.update({
          'title': _('Orphaned files'),
          'submit_label': _('Delete selected files'),
          'form': form,
          'select_all': 'selected_files',
          'node_list_title': _('The following files in the database do not exist in storage. You should fix these media objects:'),
          'node_list': broken_node_links,
      })
      return render_to_response('admin/media_tree/filenode/actions_form.html', c, context_instance=RequestContext(request))