<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -67,9 +67,11 @@ class SourcesController &lt; ApplicationController
       if @current_user and usersub=@app.memberships.find_by_user_id(@current_user.id)
         @source.credential=usersub.credential  # this variable is available in your source adapter
       end
+      
       @source.refresh(@current_user,session, app_source_url(:app_id=&gt;@app.name, :id =&gt; @source.name)) if params[:refresh] || @source.needs_refresh
       build_object_values('query',params[:client_id],params[:ack_token],params[:p_size],params[:conditions],true)
       get_wrapped_list(@object_values)
+      
       @count = @count.nil? ? @object_values.length : @count
       handle_show_format
     end</diff>
      <filename>app/controllers/sources_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -289,10 +289,18 @@ module SourcesHelper
   def build_object_values(utype=nil,client_id=nil,ack_token=nil,p_size=nil,conditions=nil,by_source=nil)
     # if client_id is provided, return only relevant objects for that client
     if client_id
+
       @client = setup_client(client_id)
       @ack_token = ack_token
       @first_request=false
       @resend_token=nil
+      
+      if @source.needs_refresh
+        if @source.is_paged?
+          @object_values=[]
+          return
+        end
+      end
 
       # setup the conditions to handle the client request
       if @ack_token</diff>
      <filename>app/helpers/sources_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -97,7 +97,7 @@ class Source &lt; ActiveRecord::Base
   def refresh(current_user, session, url=nil)
     # if we have page method then entire dosync will be called in the background
     source_adapter=setup_credential_adapter(current_user,session)
-  	if source_adapter.respond_to?(:page) 
+  	if self.is_paged?
     	cmd=&quot;ruby script/runner ./jobs/dosync.rb #{current_user.id} #{id} #{url}&quot;
       logger.info &quot;Executing background job: #{cmd}&quot;
       begin 
@@ -165,7 +165,7 @@ class Source &lt; ActiveRecord::Base
       # see spec at http://wiki.rhomobile.com/index.php/Writing_RhoSync_Source_Adapters#Paged_Queries
      
       # if there is a poge method we call that, otherwise the query method
-      if source_adapter.respond_to?(:page)
+      if self.is_paged?
     		pagenum=0      
     		result=true
     		while result 
@@ -232,6 +232,10 @@ class Source &lt; ActiveRecord::Base
   def to_param
     name.gsub(/[^a-z0-9]+/i, '-') unless new_record?
   end
+  
+  def is_paged?
+    self.source_adapter.respond_to?(:page) 
+  end
 
 	# TODO: this is a bit wierd we need to test in this way  
   def self.find_by_permalink(link)</diff>
      <filename>app/models/source.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,6 +10,7 @@ module Sync
     def wrap_object_values(ovlist)
       @count = 0
       list = {}
+      return [] if @client.nil?
       temp_count = @client.client_temp_objects.count
 
       # process the ovlist (this will also include successful create objects)</diff>
      <filename>lib/sync/client_mapper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -85,7 +85,7 @@ class Customer &lt; SourceAdapter
         open(res['location']+&quot;.json&quot;) do |f|
           parsed=JSON.parse(f.read)
         end
-        return parsed[&quot;customer&quot;][&quot;id&quot;] rescue nil
+      return parsed[&quot;customer&quot;][&quot;id&quot;] rescue nil
     end
   end
  </diff>
      <filename>vendor/sync/Store/customer.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>20a831a8035d7c208d627b861d8c2eeff9e5f84d</id>
    </parent>
  </parents>
  <author>
    <name>lars</name>
    <email>larsburgess@gmail.com</email>
  </author>
  <url>http://github.com/rhomobile/rhosync/commit/62ed3d80f2ec4cdaf6ae3b3652577c83554ba8ec</url>
  <id>62ed3d80f2ec4cdaf6ae3b3652577c83554ba8ec</id>
  <committed-date>2009-11-16T12:27:11-08:00</committed-date>
  <authored-date>2009-11-16T12:27:11-08:00</authored-date>
  <message>[#262] should not be removing temp objects until background sync is complete</message>
  <tree>42299981ed03f797c1bd73cc8397e2917ba45c8a</tree>
  <committer>
    <name>lars</name>
    <email>larsburgess@gmail.com</email>
  </committer>
</commit>
