Made _stopSharing and _stopOutgoingShare more fault-tolerant (they will no longer die if the expected annotation is missing.
authorjonathandicarlo@jonathan-dicarlos-macbook-pro.local
Tue, 01 Jul 2008 09:58:00 -0700
changeset 44868 1449de7da8d2cd995bb1e99254932faf949e5af9
parent 44867 fa59334ba99df22209d1d12bf03dd302d7fe24b6
child 44869 202c0700c094d5b963df40aad286f746ca7c4697
push id14033
push useredward.lee@engineering.uiuc.edu
push dateWed, 23 Jun 2010 22:21:35 +0000
treeherderautoland@227db4ad8cdf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
Made _stopSharing and _stopOutgoingShare more fault-tolerant (they will no longer die if the expected annotation is missing.
services/sync/modules/engines/bookmarks.js
services/sync/modules/service.js
--- a/services/sync/modules/engines/bookmarks.js
+++ b/services/sync/modules/engines/bookmarks.js
@@ -242,28 +242,24 @@ BookmarksSharingManager.prototype = {
   },
 
   _stopSharing: function BmkSharing__stopSharing( selectedFolder, username ) {
     let self = yield;
     dump( "selectedFolder is of type: " + typeof selectedFolder + "\n");
     dump( "Value is " + selectedFolder  + "\n");
     let folderName = selectedFolder.getAttribute( "label" );
     let folderNode = selectedFolder.node;
-    // This line is getting a NS_ERROR_NOT_AVAILABLE.  Is that a problem
-    // with folderNode.itemId or with annoSvc?
-    if ( folderNode.itemId == undefined ) {
-      dump( "FolderNode.itemId is undefined!!\n" );
+
+    if (this._annoSvc.itemHasAnnotation(folderNode.itemId, SERVER_PATH_ANNO)){
+      let serverPath = this._annoSvc.getItemAnnotation(folderNode.itemId,
+                                                       SERVER_PATH_ANNO);
     } else {
-      dump( "folderNode.itemId is " + folderNode.itemId +"\n");
+      this._log.warn("The folder you are de-sharing has no path annotation.");
+      let serverPath = "";
     }
-    if (!this._annoSvc.itemHasAnnotation(folderNode.itemId, SERVER_PATH_ANNO)){
-      dump( "Expected annotation not found!!\n" );
-    }
-    let serverPath = this._annoSvc.getItemAnnotation(folderNode.itemId,
-                                                     SERVER_PATH_ANNO);
 
     /* LONGTERM TODO: when we move to being able to share one folder with
      * multiple people, this needs to be modified so we can stop sharing with
      * one person but keep sharing with others.
      */
 
     // Stop the outgoing share:
     this._stopOutgoingShare.async( this, self.cb, selectedFolder);
@@ -455,32 +451,30 @@ BookmarksSharingManager.prototype = {
     self.done();
   },
 
   _stopOutgoingShare: function BmkSharing__stopOutgoingShare(folderNode) {
     /* Stops sharing the specified folder.  Deletes its data from the
        server, deletes the annotations that mark it as shared, and sends
        a message to the shar-ee to let them know it's been withdrawn. */
     let self = yield;
-    let serverPath = this._annoSvc.getItemAnnotation( folderNode,
+    if (this._annoSvc.itemHasAnnotation(folderNode.itemId, SERVER_PATH_ANNO)){
+      let serverPath = this._annoSvc.getItemAnnotation( folderNode,
                                                       SERVER_PATH_ANNO );
-    let username = this._annoSvc.getItemAnnotation( folderNode,
-                                                    OUTGOING_SHARED_ANNO );
-
-    // Delete the share from the server:
-    // TODO handle error that can happen if these resources do not exist.
-    let keyringFile = new Resource(serverPath + "/" + KEYRING_FILE_NAME);
-    keyringFile.delete(self.cb);
-    yield;
-    let bmkFile = new Resource(serverPath + "/" + SHARED_BOOKMARK_FILE_NAME);
-    keyringFile.delete(self.cb);
-    yield;
-    // TODO this leaves the folder itself in place... is there a way to
-    // get rid of that, say through DAV?
-
+      // Delete the share from the server:
+      // TODO handle error that can happen if these resources do not exist.
+      let keyringFile = new Resource(serverPath + "/" + KEYRING_FILE_NAME);
+      keyringFile.delete(self.cb);
+      yield;
+      let bmkFile = new Resource(serverPath + "/" + SHARED_BOOKMARK_FILE_NAME);
+      keyringFile.delete(self.cb);
+      yield;
+      // TODO this leaves the folder itself in place... is there a way to
+      // get rid of that, say through DAV?
+    }
     // Remove the annotations from the local folder:
     this._annoSvc.setItemAnnotation(folderNode,
                                     SERVER_PATH_ANNO,
                                     "",
                                     0,
                                     this._annoSvc.EXPIRE_NEVER);
     this._annoSvc.setItemAnnotation(folderNode,
                                     OUTGOING_SHARED_ANNO,
--- a/services/sync/modules/service.js
+++ b/services/sync/modules/service.js
@@ -798,25 +798,27 @@ WeaveSvc.prototype = {
 					saved_isShareEnabled,
                                         saved_guid,
                                     saved_username)).async(self,
 							   saved_onComplete);
 	  os.removeObserver(observer, successMsg);
 	  os.removeObserver(observer, errorMsg);
 	}
       },
-      QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]);
+      QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver])
     };
 
     if (Weave.DAV.locked) {
       /* then we have to wait until it's not locked. */
+      dump( "DAV is locked, gonna set up observer to do it later.\n");
       os.addObserver( observer, successMsg, true );
       os.addObserver( observer, errorMsg, true );
     } else {
       // Just do it right now!
+      dump( "DAV not locked, doing it now.\n");
       observer.observe();
     }
   },
 
   _shareData: function WeaveSvc__shareData(dataType,
 					   isShareEnabled,
                                            guid,
                                            username) {