Parcourir la source

[2439] Refactor: unify common code

There'll be more of this code soon, to check the zone data.
Michal 'vorner' Vaner il y a 12 ans
Parent
commit
a55716a040
1 fichiers modifiés avec 10 ajouts et 4 suppressions
  1. 10 4
      src/bin/xfrin/xfrin.py.in

+ 10 - 4
src/bin/xfrin/xfrin.py.in

@@ -429,8 +429,7 @@ class XfrinIXFRAdd(XfrinState):
             if soa_serial == conn._end_serial:
                 # The final part is there. Check all was signed
                 # and commit it to the database.
-                conn._check_response_tsig_last()
-                conn._diff.commit()
+                conn._finish_transfer()
                 self.set_xfrstate(conn, XfrinIXFREnd())
                 return True
             elif soa_serial != conn._current_serial:
@@ -507,8 +506,7 @@ class XfrinAXFREnd(XfrinState):
         indicating there will be no more message to receive.
 
         """
-        conn._check_response_tsig_last()
-        conn._diff.commit()
+        conn._finish_transfer()
         return False
 
 class XfrinTransferStats:
@@ -805,6 +803,14 @@ class XfrinConnection(asyncore.dispatcher):
                 raise XfrinProtocolError('TSIG verify fail: no TSIG on last '+
                                          'message')
 
+    def _finish_transfer(self):
+        """
+        Perform any necessary checks after a transfer. Then complete the
+        transfer by commiting the transaction into the data source.
+        """
+        self._check_response_tsig_last()
+        self._diff.commit()
+
     def __parse_soa_response(self, msg, response_data):
         '''Parse a response to SOA query and extract the SOA from answer.