problem with will_paginate and total_pages

I think I am observing a bug with the total_pages count returned from
my will_paginate collection. Or, is there some other page count I can
use that is more reliable?

I have a paginated list with a search box that is used to filter the
list. The search string generates a :conditions clause that is used
to narrow the list.

My problem is that the paginate collection.total_pages count is
incoreect. It reflects the size of the collection before
the :conditions. Here is the code:

    args = { :page => params[:page], :per_page => 10, :order => "id
desc" }
    if params[:file_filter]
      args[:conditions] = ["file_fullpath LIKE ?",
    @files = @job.files.paginate(args)

The really annoying thing is the will_paginate view helper knows the
truth and generates the page number links correctly. Looking at the
code it appears that the link renderer is using total_pages. But when
I access it from my code it returns the too-large value.