Resource.js now always validates the cache (VALIDATE_ALWAYS) when downloading stuff. This seems to fix bug 480270 on Firefox but not on Fennec.
authorjonathandicarlo@jonathan-dicarlos-macbook-pro.local
Fri, 27 Feb 2009 18:28:26 -0800
changeset 45305 fd33bc5afaebce05b5eb0b4951de4d3a054c7f5f
parent 45304 f7804280b370ffac6b0047b28508a5dab5f762e2
child 45306 e364127c5e1c6b1171041101348cea8ffbdd264e
push idunknown
push userunknown
push dateunknown
bugs480270
Resource.js now always validates the cache (VALIDATE_ALWAYS) when downloading stuff. This seems to fix bug 480270 on Firefox but not on Fennec.
services/sync/modules/engines/tabs.js
services/sync/modules/resource.js
services/sync/modules/service.js
--- a/services/sync/modules/engines/tabs.js
+++ b/services/sync/modules/engines/tabs.js
@@ -171,17 +171,17 @@ TabStore.prototype = {
       let window = session.windows[i];
       /* For some reason, session store uses one-based array index references,
         (f.e. in the "selectedWindow" and each tab's "index" properties), so we
         convert them to and from JavaScript's zero-based indexes as needed. */
       let windowID = i + 1;
 
       for (let j = 0; j < window.tabs.length; j++) {
         let tab = window.tabs[j];
-	this._log.debug( "tab state: " + uneval(tab));//this._sessionStore.getTabState(tab));
+	//this._sessionStore.getTabState(tab));
 	// Skip empty (i.e. just-opened, no history yet) tabs:
 	if (tab.entries.length == 0)
 	  continue;
 	let currentPage = tab.entries[tab.entries.length - 1];
 	/* TODO not always accurate -- if you've hit Back in this tab, then the current
 	 * page might not be the last entry.  Deal with this later.
 	 */
         this._log.debug("Wrapping a tab with title " + currentPage.title);
@@ -209,68 +209,58 @@ TabStore.prototype = {
       let urlHistory = [url];
       // TODO how to get older entries in urlHistory?
       dump("Making tab with title = " + title + ", url = " + url + "\n");
       record.addTab(title, urlHistory);
     }
   },
 
   itemExists: function TabStore_itemExists(id) {
-    this._log.debug("ItemExists called.");
     if (id == this._localClientGUID) {
-      this._log.debug("It's me.");
       return true;
     } else if (this._remoteClients[id]) {
-      this._log.debug("It's somebody else.");
       return true;
     } else {
-      this._log.debug("It doesn't exist!");
       return false;
     }
   },
 
   createRecord: function TabStore_createRecord(id, cryptoMetaURL) {
-    this._log.debug("CreateRecord called for id " + id );
     let record;
     if (id == this._localClientGUID) {
-      this._log.debug("That's Me!");
       record = this._createLocalClientTabSetRecord();
     } else {
-      this._log.debug("That's Somebody Else.");
       record = this._remoteClients[id];
     }
     record.id = id;
     record.encryption = cryptoMetaURL;
     return record;
   },
 
   changeItemId: function TabStore_changeItemId(oldId, newId) {
-    this._log.debug("changeItemId called.");
     if (this._remoteClients[oldId]) {
       let record = this._remoteClients[oldId];
       record.id = newId;
       delete this._remoteClients[oldId];
       this._remoteClients[newId] = record;
     }
   },
 
   getAllIDs: function TabStore_getAllIds() {
-    this._log.debug("getAllIds called.");
     let items = {};
     items[ this._localClientGUID ] = true;
     for (let id in this._remoteClients) {
       items[id] = true;
     }
     return items;
   },
 
   wipe: function TabStore_wipe() {
     this._log.debug("Wipe called.  Clearing cache of remote client tabs.");
     this._remoteClients = {};
-    this._writeToFile();
   },
 
   create: function TabStore_create(record) {
     if (record.id == this._localClientGUID)
       return; // can't happen?
     this._log.debug("Create called.  Adding remote client record for ");
     this._log.debug(record.getClientName());
     this._remoteClients[record.id] = record;
--- a/services/sync/modules/resource.js
+++ b/services/sync/modules/resource.js
@@ -143,17 +143,23 @@ Resource.prototype = {
     this._headers = {'Content-type': 'text/plain'};
     this._filters = [];
   },
 
   _createRequest: function Res__createRequest() {
     let ios = Cc["@mozilla.org/network/io-service;1"].
       getService(Ci.nsIIOService);
     this._lastChannel = ios.newChannel(this.spec, null, null).
-      QueryInterface(Ci.nsIHttpChannel);
+      QueryInterface(Ci.nsIRequest);
+    // Always validate the cache:
+    let loadFlags = this._lastChannel.loadFlags;
+    loadFlags |= Ci.nsIRequest.VALIDATE_ALWAYS;
+    this._lastChannel.loadFlags = loadFlags;
+    this._lastChannel = this._lastChannel.QueryInterface(Ci.nsIHttpChannel);
+
     this._lastChannel.notificationCallbacks = new badCertListener();
 
     let headers = this.headers; // avoid calling the authorizer more than once
     for (let key in headers) {
       if (key == 'Authorization')
         this._log.trace("HTTP Header " + key + ": ***** (suppressed)");
       else
         this._log.trace("HTTP Header " + key + ": " + headers[key]);
--- a/services/sync/modules/service.js
+++ b/services/sync/modules/service.js
@@ -569,17 +569,19 @@ WeaveSvc.prototype = {
   _remoteSetup: function WeaveSvc__remoteSetup() {
     let self = yield;
     let ret = false; // false to abort sync
     let reset = false;
 
     this._log.debug("Fetching global metadata record");
     let meta = yield Records.import(self.cb, this.clusterURL +
 				    this.username + "/meta/global");
-
+    
+    this._log.debug("Min server storage version is " + MIN_SERVER_STORAGE_VERSION);
+    this._log.debug("payload storage version is " + meta.payload.storageVersion);
     if (!meta || !meta.payload.storageVersion || !meta.payload.syncID ||
         Svc.Version.compare(MIN_SERVER_STORAGE_VERSION,
                             meta.payload.storageVersion) > 0) {
       // abort the server wipe if the GET status was anything other than 404 or 200
       let status = Records.lastResource.lastChannel.responseStatus;
       if (status != 200 && status != 404) {
 	this._log.warn("Unknown error while downloading metadata record.  " +
 			"Aborting sync.");
@@ -806,16 +808,17 @@ WeaveSvc.prototype = {
     let self = yield;
 
     this._wipeClientMetadata();
     this._log.info("Client metadata wiped, deleting server data");
     yield this._wipeServer.async(this, self.cb);
 
     this._log.debug("Uploading new metadata record");
     meta = new WBORecord(this.clusterURL + this.username + "/meta/global");
+    this._log.debug("Setting meta payload storage version to " + WEAVE_VERSION);
     meta.payload.storageVersion = WEAVE_VERSION;
     meta.payload.syncID = Clients.syncID;
     let res = new Resource(meta.uri);
     yield res.put(self.cb, meta.serialize());
   },
 
   // XXX deletes all known collections; we should have a way to delete
   //     everything on the server by querying it to get all collections