Remove needlessly complex error handling code from vardbapi.cpv_counter().
authorZac Medico <zmedico@gentoo.org>
Tue, 21 Oct 2008 21:05:18 +0000 (21:05 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 21 Oct 2008 21:05:18 +0000 (21:05 -0000)
svn path=/main/trunk/; revision=11711

pym/portage/dbapi/vartree.py

index ceae2ff313ef012aff5bd22ce2a4358a19dc42bf..6bc960ff07ea6c493cee2c10ae0ba9360988fe4e 100644 (file)
@@ -672,53 +672,10 @@ class vardbapi(dbapi):
                        return long(self.aux_get(mycpv, ["COUNTER"])[0])
                except (KeyError, ValueError):
                        pass
-               cdir = self.getpath(mycpv)
-               cpath = self.getpath(mycpv, filename="COUNTER")
-
-               # We write our new counter value to a new file that gets moved into
-               # place to avoid filesystem corruption on XFS (unexpected reboot.)
-               corrupted = 0
-               if os.path.exists(cpath):
-                       cfile = open(cpath, "r")
-                       try:
-                               counter = long(cfile.readline())
-                       except ValueError:
-                               print "portage: COUNTER for", mycpv, "was corrupted; resetting to value of 0"
-                               counter = long(0)
-                               corrupted = 1
-                       cfile.close()
-               elif os.path.exists(cdir):
-                       mys = pkgsplit(mycpv)
-                       myl = self.match(mys[0], use_cache=0)
-                       print mys, myl
-                       if len(myl) == 1:
-                               try:
-                                       # Only one package... Counter doesn't matter.
-                                       write_atomic(cpath, "1")
-                                       counter = 1
-                               except SystemExit, e:
-                                       raise
-                               except Exception, e:
-                                       writemsg("!!! COUNTER file is missing for "+str(mycpv)+" in /var/db.\n",
-                                               noiselevel=-1)
-                                       writemsg("!!! Please run %s/fix-db.py or\n" % PORTAGE_BIN_PATH,
-                                               noiselevel=-1)
-                                       writemsg("!!! unmerge this exact version.\n", noiselevel=-1)
-                                       writemsg("!!! %s\n" % e, noiselevel=-1)
-                                       sys.exit(1)
-                       else:
-                               writemsg("!!! COUNTER file is missing for "+str(mycpv)+" in /var/db.\n",
-                                       noiselevel=-1)
-                               writemsg("!!! Please run %s/fix-db.py or\n" % PORTAGE_BIN_PATH,
-                                       noiselevel=-1)
-                               writemsg("!!! remerge the package.\n", noiselevel=-1)
-                               sys.exit(1)
-               else:
-                       counter = long(0)
-               if corrupted:
-                       # update new global counter file
-                       write_atomic(cpath, str(counter))
-               return counter
+               writemsg_level(("portage: COUNTER for %s was corrupted; " + \
+                       "resetting to value of 0\n") % (mycpv,),
+                       level=logging.ERROR, noiselevel=-1)
+               return 0
 
        def cpv_inject(self, mycpv):
                "injects a real package into our on-disk database; assumes mycpv is valid and doesn't already exist"