-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Zac Medico wrote: > I've implemented whiteouts so that items can now be deleted properly. The > whiteouts themselves are stored inside the existing writable database > (self.db_rw) in order to avoid the need for an additional storage area > (similar to unionfs whiteouts which are implemented as hidden files). > > The whiteouts (if they exist) are validated on access and removed if > necessary. A whiteout is considered invalid if it's _mtime_ and _eclasses_ > are not exactly equal to underlying database entry that it erases (or the > underlying database entry no longer exists). This should cause whiteouts to > be automatically invalidated whenever the underlying cache changes.
Here's a small patch to the previous module that compares the values given in a _setitem call to the underlying db_ro in order to ensure that the writable layer remains empty whenever possible. Zac -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) iD8DBQFD3J8y/ejvha5XGaMRAv8OAKC3o4mLjIJPXtb/wTG/9p/lW2YOUwCfcYc6 9uDb6WJdjg1it6h/H5FoSRs= =jLFW -----END PGP SIGNATURE-----
--- metadata_overlay.py.orig 2006-01-29 01:57:12.000000000 -0800 +++ metadata_overlay.py 2006-01-29 02:31:27.000000000 -0800 @@ -35,7 +35,17 @@ return value def _setitem(self, name, values): - self.db_rw[name] = values + try: + value_ro = self.db_ro[name] + if self._are_values_identical(value_ro,values): + # we have matching values in the underlying db_ro + # so it is unnecessary to store data in db_rw + try: + del self.db_rw[name] # delete unwanted whiteout when necessary + except KeyError: + pass + except KeyError: + self.db_rw[name] = values def _delitem(self, cpv): value = self[cpv] # validates whiteout and/or raises a KeyError when necessary @@ -71,8 +81,11 @@ def _is_whiteout_valid(self, name, value_rw): try: value_ro = self.db_ro[name] - if long(value_rw["_mtime_"]) != long(value_ro["_mtime_"]): - return False - return value_rw["_eclasses_"] == value_ro["_eclasses_"] + return self._are_values_identical(value_rw,value_ro) except KeyError: return False + + def _are_values_identical(self, value1, value2): + if long(value1["_mtime_"]) != long(value2["_mtime_"]): + return False + return value1["_eclasses_"] == value2["_eclasses_"]