emerge --sync: discard timestamp for partial sync
authorZac Medico <zmedico@gentoo.org>
Sat, 24 Aug 2013 16:07:13 +0000 (09:07 -0700)
committerZac Medico <zmedico@gentoo.org>
Sat, 24 Aug 2013 16:12:07 +0000 (09:12 -0700)
pym/_emerge/actions.py

index 52ceba49e2cdaf57fcf8b236c7aaae03bcd74d56..bb6e4969072b9f5f4c05957537d2400bcf771f39 100644 (file)
@@ -2533,8 +2533,31 @@ def _sync_repo(emerge_config, repo):
                                elif (servertimestamp == 0) or (servertimestamp > mytimestamp):
                                        # actual sync
                                        mycommand = rsynccommand + [dosyncuri+"/", repo.location]
-                                       exitcode = portage.process.spawn(mycommand,
-                                               **portage._native_kwargs(spawn_kwargs))
+                                       exitcode = None
+                                       try:
+                                               exitcode = portage.process.spawn(mycommand,
+                                                       **portage._native_kwargs(spawn_kwargs))
+                                       finally:
+                                               if exitcode is None:
+                                                       # interrupted
+                                                       exitcode = 128 + signal.SIGINT
+
+                                       #   0   Success
+                                       #   1   Syntax or usage error
+                                       #   2   Protocol incompatibility
+                                       #   5   Error starting client-server protocol
+                                       #  35   Timeout waiting for daemon connection
+                                       if exitcode not in (0, 1, 2, 5, 35):
+                                               # If the exit code is not among those listed above,
+                                               # then we may have a partial/inconsistent sync state,
+                                               # so our previously read timestamp as well as the
+                                               # corresponding file can no longer be trusted.
+                                               mytimestamp = 0
+                                               try:
+                                                       os.unlink(servertimestampfile)
+                                               except OSError:
+                                                       pass
+
                                        if exitcode in [0,1,3,4,11,14,20,21]:
                                                break
                        elif exitcode in [1,3,4,11,14,20,21]: