~jelmer/bzr-hg/lp-pqm

« back to all changes in this revision

Viewing changes to idmap.py

  • Committer: Jelmer Vernooij
  • Date: 2009-12-13 00:18:28 UTC
  • Revision ID: jelmer@samba.org-20091213001828-xlbtb7fruj6hwdts
Avoid iterating over all keys in the tdb database.

Show diffs side-by-side

added added

removed removed

Lines of Context:
119
119
                mapdbs()[path] = tdb.Tdb(path, TDB_HASH_SIZE, tdb.DEFAULT,
120
120
                                          os.O_RDWR|os.O_CREAT)
121
121
            self.db = mapdbs()[path]
122
 
        if not "version" in self.db:
123
 
            self.db["version"] = str(TDB_MAP_VERSION)
124
 
        else:
 
122
        try:
125
123
            if int(self.db["version"]) != TDB_MAP_VERSION:
126
124
                trace.warning("SHA Map is incompatible (%s -> %d), rebuilding database.",
127
125
                              self.db["version"], TDB_MAP_VERSION)
128
126
                self.db.clear()
 
127
                self.db["version"] = str(TDB_MAP_VERSION)
 
128
        except KeyError:
129
129
            self.db["version"] = str(TDB_MAP_VERSION)
130
130
 
131
131
    @classmethod