Bug 819584 - [SMS] Don't perform an upgrade of existing sms yet. r=sicking

This commit is contained in:
Gregor Wagner 2012-12-07 16:16:30 -08:00
Родитель db29898f44
Коммит b77e5e4e04
1 изменённых файлов: 1 добавлений и 74 удалений

Просмотреть файл

@ -363,80 +363,7 @@ SmsDatabaseService.prototype = {
},
upgradeSchema5: function upgradeSchema5(transaction) {
let smsStore = transaction.objectStore(STORE_NAME);
let mostRecentStore = transaction.objectStore(MOST_RECENT_STORE_NAME);
smsStore.openCursor().onsuccess = function(event) {
let cursor = event.target.result;
if (!cursor) {
return;
}
let needsUpdate = false;
let message = cursor.value;
if (message.receiver) {
if (message.receiver !== "undefined") {
if (DEBUG) debug("upgrade message.receiver from: " + message.receiver + "\n");
let parsedNumber = PhoneNumberUtils.parse(message.receiver.toString());
if (parsedNumber && parsedNumber.internationalNumber) {
message.receiver = parsedNumber.internationalNumber;
needsUpdate = true;
}
if (DEBUG) debug("upgrade message.receiver to: " + message.receiver + "\n");
} else {
message.receiver = null;
needsUpdate = true;
}
}
if (message.sender) {
if (message.sender !== "undefined") {
if (DEBUG) debug("upgrade message.sender from: " + message.sender + "\n");
let parsedNumber = PhoneNumberUtils.parse(message.sender.toString());
if (parsedNumber && parsedNumber.internationalNumber) {
message.sender = parsedNumber.internationalNumber;
needsUpdate = true;
if (DEBUG) debug("upgrade message.sender to: " + message.sender + "\n");
}
} else {
message.sender = null;
needsUpdate = true;
}
}
if (needsUpdate) {
cursor.update(message);
}
cursor.continue();
}
// We want to avoid walking over entries we just added.
// cursor.update doesn't work because we are modifying the primary key.
let updateArray = [];
mostRecentStore.openCursor().onsuccess = function(event) {
let cursor = event.target.result;
if (!cursor) {
return;
}
let entry = cursor.value;
if (entry.senderOrReceiver) {
if (DEBUG) debug("upgrade mostRecentStore from: " + entry.senderOrReceiver + "\n");
let parsedNumber = PhoneNumberUtils.parse(entry.senderOrReceiver);
if (parsedNumber && parsedNumber.internationalNumber) {
entry.senderOrReceiver = parsedNumber.internationalNumber;
updateArray.push(entry);
cursor.delete();
if (DEBUG) debug("upgrade mostRecentStore to: " + entry.senderOrReceiver + "\n");
}
}
cursor.continue();
}
for each (entry in updateArray) {
mostRecentStore.put(entry);
}
// Don't perform any upgrade. See Bug 819560.
},
/**