Merge lp:~urbanape/bindwood/fixing-broken-migration into lp:bindwood

Proposed by Zachery Bir
Status: Merged
Approved by: Martin Albisetti
Approved revision: 27
Merged at revision: not available
Proposed branch: lp:~urbanape/bindwood/fixing-broken-migration
Merge into: lp:bindwood
Diff against target: 163 lines (+24/-10)
2 files modified
install.rdf (+1/-1)
modules/bindwood.jsm (+23/-9)
To merge this branch: bzr merge lp:~urbanape/bindwood/fixing-broken-migration
Reviewer Review Type Date Requested Status
Martin Albisetti (community) Approve
Eric Casteleijn (community) Approve
Review via email: mp+23423@code.launchpad.net

Description of the change

This branch fixes particularly broken migrations that got part-way finished but never completed, and so will now get into apparently infinite waits.

To post a comment you must log in.
Revision history for this message
Eric Casteleijn (thisfred) wrote :

Builds, installs, and works as advertised!

review: Approve
Revision history for this message
Martin Albisetti (beuno) wrote :

Thanks for the quick fix. It makes it work for me, so YAY.

My only suggestion is maybe filing a bug to track those XXX's, but I don't know if it's too generic (ie "make bindwood migration more robust").

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'install.rdf'
2--- install.rdf 2010-04-04 14:03:38 +0000
3+++ install.rdf 2010-04-14 19:10:39 +0000
4@@ -4,7 +4,7 @@
5
6 <Description about="urn:mozilla:install-manifest">
7 <em:id>bindwood@ubuntu.com</em:id>
8- <em:version>1.0.3</em:version>
9+ <em:version>1.0.4</em:version>
10 <em:type>2</em:type>
11
12 <!-- Target Application this extension can install into,
13
14=== modified file 'modules/bindwood.jsm'
15--- modules/bindwood.jsm 2010-04-02 03:29:36 +0000
16+++ modules/bindwood.jsm 2010-04-14 19:10:39 +0000
17@@ -340,6 +340,8 @@
18 // Neither the profile root exists, nor do we have a last_seq.
19 // Ergo, we are a first time user. Proceed normally.
20
21+ /* Disabling the pop-up window for the time being
22+
23 Bindwood.statusWindow = windowService.openWindow(
24 null,
25 "chrome://bindwood/content/first-time.html",
26@@ -351,12 +353,15 @@
27 var dots = div.innerHTML;
28 div.innerHTML = dots + ".";
29 } }, 1000, Ci.nsITimer.TYPE_REPEATING_SLACK);
30+ */
31 break;
32 case 1:
33 // We have a last_seq, but the profile root does not exist.
34 // Ergo, we are an old user and must migrate to the new way of
35 // doing things.
36
37+ /* Disabling the pop-up window for the time being
38+
39 Bindwood.statusWindow = windowService.openWindow(
40 null,
41 "chrome://bindwood/content/migrate-old-bookmarks.html",
42@@ -368,6 +373,7 @@
43 var dots = div.innerHTML;
44 div.innerHTML = dots + ".";
45 } }, 1000, Ci.nsITimer.TYPE_REPEATING_SLACK);
46+ */
47 // Migrate all existing records in Couch
48 Bindwood.migrateOlderBookmarkRecords();
49 // Ensure that all local records are pushed
50@@ -379,6 +385,8 @@
51 // bookmarks look like remote, and ensure that any unaccounted for
52 // local bookmarks are sent to CouchDB.
53
54+ /* Disabling the pop-up window for the time being
55+
56 Bindwood.statusWindow = windowService.openWindow(
57 null,
58 "chrome://bindwood/content/subsequent-client-first-time-sync.html",
59@@ -390,6 +398,7 @@
60 var dots = div.innerHTML;
61 div.innerHTML = dots + ".";
62 } }, 1000, Ci.nsITimer.TYPE_REPEATING_SLACK);
63+ */
64 // Sync all existing records in Couch and local records
65 Bindwood.handleSubsequentClientFirstTimeSync();
66 // Ensure that all local records are pushed
67@@ -502,7 +511,11 @@
68 "Let's migrate the remote records and re-sync.");
69
70 var additional = [];
71- var all_docs = Bindwood.couch.allDocs();
72+ var all_docs = Bindwood.couch.view("bookmarks/profile",
73+ {
74+ startkey: Bindwood.currentProfile,
75+ endkey: Bindwood.currentProfile
76+ });
77 var rows = all_docs.rows;
78
79 // Pull all records from Couch, and for each:
80@@ -515,9 +528,9 @@
81 var doc = Bindwood.couch.open(id);
82 Bindwood.writeMessage("Got a doc: " + doc);
83
84- if (!Bindwood.recordInCurrentProfile(doc)) {
85+ if (doc.record_type_version >= 1) {
86 Bindwood.writeMessage(
87- "Record isn't in our current profile. Skipping...");
88+ "Record is already migrated Skipping...");
89 continue;
90 }
91
92@@ -526,6 +539,7 @@
93 Bindwood.writeMessage(
94 "Got the old uuid from the record: " + old_uuid);
95 // look up itemId by uuid
96+ // XXX: This probably needs to be made more robust
97 var itemId = Bindwood.itemIdForUUID(old_uuid);
98 Bindwood.writeMessage(
99 "Found its local itemID from the map: " + itemId);
100@@ -581,6 +595,7 @@
101 // populated, and in particular make sure that we've already
102 // modified their children's annotations/uuids
103 if (doc.record_type == Bindwood.TYPE_FOLDER) {
104+ // XXX: This probably needs to be made more robust
105 var itemId = Bindwood.itemIdForUUID(doc._id);
106 doc.children = Bindwood.getUUIDsFromFolder(itemId);
107 Bindwood.writeMessage(
108@@ -1047,9 +1062,12 @@
109 Bindwood.writeError("Problem setting up repeater.", e);
110 }
111
112+ /* Disabling pop-up window for the time being.
113+
114 if (Bindwood.statusWindow) {
115 Bindwood.reportDoneInWindow();
116 }
117+ */
118 },
119
120 reportDoneInWindow: function() {
121@@ -1260,6 +1278,7 @@
122 " to scratch folder");
123 for (var i = 0; i<local_children.length; i++) {
124 var child = local_children[i];
125+ // XXX: Probably needs to be made more robust
126 var child_itemId = Bindwood.itemIdForUUID(child);
127 try {
128 bookmarksService.moveItem(
129@@ -1275,6 +1294,7 @@
130 JSON.stringify(record.children) + " to this folder");
131 for (var j = 0; j<record.children.length; j++) {
132 var new_child = record.children[j];
133+ // XXX: Probably needs to be made more robust
134 var new_child_itemId = Bindwood.itemIdForUUID(new_child);
135 try {
136 bookmarksService.moveItem(new_child_itemId, itemId, -1);
137@@ -1424,8 +1444,6 @@
138 "A new item was created. Its id is: " + aItemId +
139 " at location: " + aIndex +
140 " in folder: " + aFolder );
141- netscape.security.PrivilegeManager.enablePrivilege(
142- "UniversalBrowserRead UniversalBrowserWrite");
143
144 switch (Bindwood.push) {
145 case 'DISABLED':
146@@ -1473,8 +1491,6 @@
147 "Deleted from local uuid map, but not saving back to Couch.");
148 break;
149 case 'ENABLED':
150- netscape.security.PrivilegeManager.enablePrivilege(
151- "UniversalBrowserRead UniversalBrowserWrite");
152
153 var doc = Bindwood.couch.open(uuid);
154 if (!doc.application_annotations) {
155@@ -1553,8 +1569,6 @@
156 case 'ENABLED':
157 Bindwood.writeMessage(
158 "We will push this change back to Couch.");
159- netscape.security.PrivilegeManager.enablePrivilege(
160- "UniversalBrowserRead UniversalBrowserWrite");
161 try {
162 var result = Bindwood.updateDocAndSave(
163 uuid, aProperty.toString(), aValue.toString(),

Subscribers

People subscribed via source and target branches