Christian Biesinger wrote:
Hm... this is definitely working for other code, such as
http://lxr.mozilla.org/seamonkey/source/browser/base/content/metaData.js#61,
so I'm not sure why it doesn't for you.
Looks like I am doing the same stuff than the code you mention.
I'm running this on firefox 1.0.8, if that may explain things.
Here is my code in case someone sees something obvious:
// invalidate http cache entries starting with given string
Util.cacheInvalidate = function(startUrl) {
var Visitor=function(urlStart) {
this.urlStart = urlStart;
this.cacheService =
Components.classes["@mozilla.org/network/cache-service;1"].
getService(Components.interfaces.nsICacheService);
this.cacheSessionStreamBased =
this.cacheService.createSession("HTTP",
Components.interfaces.nsICache.STORE_ANYWHERE,true);
this.cacheSessionNotStreamBased =
this.cacheService.createSession("HTTP",
Components.interfaces.nsICache.STORE_ANYWHERE,false);
this.cacheKeys={};
};
Visitor.prototype = {
visitDevice: function( deviceID , deviceInfo ) {
return true;
},
visitEntry: function( deviceID , entryInfo ) {
var url=entryInfo.key;
var startUrl0=url.substring(0,this.urlStart.length);
if(startUrl0==this.urlStart) {
this.cacheKeys[url] = ""+entryInfo.isStreamBased();
}
return true;
},
visitEntries: function() {
this.cacheService.visitEntries(this);
for(var key in this.cacheKeys) {
var cacheSession = this.cacheSessionNotStreamBased;
if(this.cacheKeys[key]=="true")
cacheSession = this.cacheSessionStreamBased;
dump("Cache: open entry for key "+key+"\n");
try {
var descriptor = cacheSession.openCacheEntry(key,
Components.interfaces.nsICache.ACCESS_READ, true);
dump("Cache invalidate "+url+"\n");
descriptor.doom();
} catch(e) {
dump("Cache: Exception getting entry descriptor: "+e+"\n");
}
}
}
};
var visitor=new Visitor(urlStart);
visitor.visitEntries();
}
/mig
_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom