_artifactcache/pushreceive.py: Avoid premature 'done' messages

Code exists in OSTreePusher.needed_commits() to raise a
PushExistsException() if the local commit (what we want to push) is not
a descendent of the remote commit (what the artifact cache has).

Code also exists in OSTreePusher.run() to ignore this exception, unless
there are no refs that we can push. So situations occur where the push
continues even though one of the refs can't be updated due to this
inconsistency.

That would be fine except that before we raise the PushExistsException,
we call send_done() and hang up the connection. So the push goes on to
fail with "Expected reply, got none" as the remote has already hung up.

This commit moves the send_done() call further down so that it only
happens once we know the PushExistsException is not going to be ignored.
1 file changed