Skip to content

Commit

Permalink
786762 - Sync status in the UI will now be updated properly whenever a
Browse files Browse the repository at this point in the history
user cancels and restarts a sync.
(cherry picked from commit 47040f4)
  • Loading branch information
ehelms committed Mar 2, 2012
1 parent 5f43c2b commit 92cd64a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/app/controllers/sync_management_controller.rb
Expand Up @@ -118,7 +118,6 @@ def sync_status
def destroy
retval = Repository.find(params[:id]).cancel_sync
render :text=>""

end


Expand Down
8 changes: 6 additions & 2 deletions src/app/models/glue/pulp/repo.rb
Expand Up @@ -499,9 +499,13 @@ def self.array_to_hash(array_of_repos)

def _get_most_recent_sync_status()
begin
history = [Pulp::Repository.sync_status(pulp_id)]
history = Pulp::Repository.sync_status(pulp_id)

if history.nil? or history.empty?
history = Pulp::Repository.sync_history(pulp_id)
end
rescue
history = Pulp::Repository.sync_history(pulp_id)
history = Pulp::Repository.sync_history(pulp_id)
end
return [::PulpSyncStatus.new(:state => ::PulpSyncStatus::Status::NOT_SYNCED)] if (history.nil? or history.empty?)
history.collect{|item| ::PulpSyncStatus.using_pulp_task(item)}
Expand Down
8 changes: 4 additions & 4 deletions src/lib/resources/pulp.rb
Expand Up @@ -283,7 +283,7 @@ def sync_status(repo_id)
parsed = JSON.parse(response.body)

parsed.reject!{ |task| task['start_time'].nil? }

return parsed if parsed.empty?

parsed.sort!{|a,b|
Expand All @@ -294,11 +294,11 @@ def sync_status(repo_id)
elsif b['finish_time'].nil?
1
else
a['finish_time'] <=> b['finish_time']
b['finish_time'] <=> a['finish_time']
end
}.reverse!
}

return parsed.first.with_indifferent_access
return [parsed.first.with_indifferent_access]
end

def destroy repo_id
Expand Down

0 comments on commit 92cd64a

Please sign in to comment.