--- a/toolkit/components/places/PlacesSyncUtils.jsm
+++ b/toolkit/components/places/PlacesSyncUtils.jsm
@@ -146,18 +146,18 @@ const BookmarkSyncUtils = PlacesSyncUtil
// Reorder the list, ignoring missing children.
let delta = 0;
for (let i = 0; i < childSyncIds.length; ++i) {
let guid = BookmarkSyncUtils.syncIdToGuid(childSyncIds[i]);
let child = findChildByGuid(children, guid);
if (!child) {
delta++;
- BookmarkSyncLog.trace(`order: Ignoring missing child ${
- childSyncIds[i]}`);
+ BookmarkSyncLog.trace(`order: Ignoring missing child ` +
+ childSyncIds[i]);
continue;
}
let newIndex = i - delta;
updateChildIndex(children, child, newIndex);
}
children.sort((a, b) => a.index - b.index);
// Update positions.
@@ -370,18 +370,18 @@ var updateTagQueryFolder = Task.async(fu
let params = new URLSearchParams(info.url.pathname);
let type = +params.get("type");
if (type != Ci.nsINavHistoryQueryOptions.RESULTS_AS_TAG_CONTENTS) {
return info;
}
let id = yield getOrCreateTagFolder(info.folder);
- BookmarkSyncLog.debug(`updateTagQueryFolder: Tag query folder: ${
- info.folder} = ${id}`);
+ BookmarkSyncLog.debug(`updateTagQueryFolder: Tag query folder: ` +
+ `${info.folder} = ${id}`);
// Rewrite the query to reference the new ID.
params.set("folder", id);
info.url = new URL(info.url.protocol + params);
return info;
});
@@ -400,35 +400,37 @@ var reparentOrphans = Task.async(functio
}
let orphanIds = findAnnoItems(BookmarkSyncUtils.SYNC_PARENT_ANNO, item.syncId);
// The annotations API returns item IDs, but the asynchronous bookmarks
// API uses GUIDs. We can remove the `promiseItemGuid` calls and parallel
// arrays once we implement a GUID-aware annotations API.
let orphanGuids = yield Promise.all(orphanIds.map(id =>
PlacesUtils.promiseItemGuid(id)));
let folderGuid = BookmarkSyncUtils.syncIdToGuid(item.syncId);
- BookmarkSyncLog.debug(`reparentOrphans: Reparenting ${
- JSON.stringify(orphanGuids)} to ${item.syncId}`);
+ BookmarkSyncLog.debug(`reparentOrphans: Reparenting ` +
+ `${JSON.stringify(orphanGuids)} to ` +
+ item.syncId);
for (let i = 0; i < orphanGuids.length; ++i) {
let isReparented = false;
try {
// Reparenting can fail if we have a corrupted or incomplete tree
// where an item's parent is one of its descendants.
- BookmarkSyncLog.trace(`reparentOrphans: Attempting to move item ${
- orphanGuids[i]} to new parent ${item.syncId}`);
+ BookmarkSyncLog.trace(`reparentOrphans: Attempting to move item ` +
+ `${orphanGuids[i]} to new parent ` +
+ item.syncId);
yield PlacesUtils.bookmarks.update({
guid: orphanGuids[i],
parentGuid: folderGuid,
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
source: SOURCE_SYNC,
});
isReparented = true;
} catch (ex) {
- BookmarkSyncLog.error(`reparentOrphans: Failed to reparent item ${
- orphanGuids[i]} to ${item.syncId}`, ex);
+ BookmarkSyncLog.error(`reparentOrphans: Failed to reparent item ` +
+ `${orphanGuids[i]} to ${item.syncId}`, ex);
}
if (isReparented) {
// Remove the annotation once we've reparented the item.
PlacesUtils.annotations.removeItemAnnotation(orphanIds[i],
BookmarkSyncUtils.SYNC_PARENT_ANNO, SOURCE_SYNC);
}
}
});
@@ -437,22 +439,22 @@ var reparentOrphans = Task.async(functio
var insertSyncBookmark = Task.async(function* (insertInfo) {
let requestedParentSyncId = insertInfo.parentSyncId;
let requestedParentGuid =
BookmarkSyncUtils.syncIdToGuid(insertInfo.parentSyncId);
let isOrphan = yield GUIDMissing(requestedParentGuid);
// Default to "unfiled" for new bookmarks if the parent doesn't exist.
if (!isOrphan) {
- BookmarkSyncLog.debug(`insertSyncBookmark: Item ${
- insertInfo.syncId} is not an orphan`);
+ BookmarkSyncLog.debug(`insertSyncBookmark: Item {insertInfo.syncId} ` +
+ `is not an orphan`);
} else {
- BookmarkSyncLog.debug(`insertSyncBookmark: Item ${
- insertInfo.syncId} is an orphan: parent ${
- insertInfo.parentSyncId} doesn't exist; reparenting to unfiled`);
+ BookmarkSyncLog.debug(`insertSyncBookmark: Item ${insertInfo.syncId} ` +
+ `is an orphan: parent ${insertInfo.parentSyncId} ` +
+ `doesn't exist; reparenting to unfiled`);
insertInfo.parentSyncId = "unfiled";
}
// If we're inserting a tag query, make sure the tag exists and fix the
// folder ID to refer to the local tag folder.
insertInfo = yield updateTagQueryFolder(insertInfo);
let newItem;
@@ -477,29 +479,29 @@ var insertSyncBookmark = Task.async(func
yield reparentOrphans(newItem);
return newItem;
});
// Inserts a synced livemark.
var insertSyncLivemark = Task.async(function* (insertInfo) {
if (!insertInfo.feed) {
- BookmarkSyncLog.debug(`insertSyncLivemark: ${
- insertInfo.syncId} missing feed URL`);
+ BookmarkSyncLog.debug(`insertSyncLivemark: ${insertInfo.syncId} ` +
+ `missing feed URL`);
return null;
}
let livemarkInfo = syncBookmarkToPlacesBookmark(insertInfo);
let parentId = yield PlacesUtils.promiseItemId(livemarkInfo.parentGuid);
let parentIsLivemark = PlacesUtils.annotations.itemHasAnnotation(parentId,
PlacesUtils.LMANNO_FEEDURI);
if (parentIsLivemark) {
// A livemark can't be a descendant of another livemark.
- BookmarkSyncLog.debug(`insertSyncLivemark: Invalid parent ${
- insertInfo.parentSyncId}; skipping livemark record ${
- insertInfo.syncId}`);
+ BookmarkSyncLog.debug(`insertSyncLivemark: Invalid parent ` +
+ `${insertInfo.parentSyncId}; skipping ` +
+ `livemark record ${insertInfo.syncId}`);
return null;
}
let livemarkItem = yield PlacesUtils.livemarks.addLivemark(livemarkInfo);
return insertBookmarkMetadata(livemarkItem, insertInfo);
});
@@ -515,18 +517,18 @@ var insertBookmarkMetadata = Task.async(
PlacesUtils.annotations.EXPIRE_NEVER,
SOURCE_SYNC);
newItem.query = insertInfo.query;
}
try {
newItem.tags = yield tagItem(bookmarkItem, insertInfo.tags);
} catch (ex) {
- BookmarkSyncLog.warn(`insertBookmarkMetadata: Error tagging item ${
- insertInfo.syncId}`, ex);
+ BookmarkSyncLog.warn(`insertBookmarkMetadata: Error tagging item ` +
+ insertInfo.syncId, ex);
}
if (insertInfo.keyword) {
yield PlacesUtils.keywords.insert({
keyword: insertInfo.keyword,
url: bookmarkItem.url.href,
source: SOURCE_SYNC,
});
@@ -618,45 +620,45 @@ var shouldReinsertLivemark = Task.async(
if (!livemark.siteURI || !siteURI.equals(livemark.siteURI)) {
return true;
}
}
return false;
});
var updateSyncBookmark = Task.async(function* (updateInfo) {
- let guid = BookmarkSyncUtils.syncIdToGuid(updateInfo.syncId);
+ let oldSyncId = updateInfo.syncId;
+ let guid = BookmarkSyncUtils.syncIdToGuid(oldSyncId);
let oldBookmarkItem = yield PlacesUtils.bookmarks.fetch(guid);
if (!oldBookmarkItem) {
- throw new Error(`Bookmark with sync ID ${
- updateInfo.syncId} does not exist`);
+ throw new Error(`Bookmark with sync ID ${oldSyncId} does not exist`);
}
let shouldReinsert = false;
let oldKind = yield getKindForItem(oldBookmarkItem);
if (updateInfo.hasOwnProperty("kind") && updateInfo.kind != oldKind) {
// If the item's aren't the same kind, we can't update the record;
// we must remove and reinsert.
shouldReinsert = true;
if (BookmarkSyncLog.level <= Log.Level.Warn) {
- let oldSyncId = BookmarkSyncUtils.guidToSyncId(oldBookmarkItem.guid);
- BookmarkSyncLog.warn(`updateSyncBookmark: Local ${
- oldSyncId} kind = ${oldKind}; remote ${
- updateInfo.syncId} kind = ${
- updateInfo.kind}. Deleting and recreating`);
+ let { syncId: newSyncId, kind: newKind } = updateInfo;
+ BookmarkSyncLog.warn(`updateSyncBookmark: ` +
+ `Local ${oldSyncId} kind = ${oldKind}; ` +
+ `remote ${newSyncId} kind = ${newKind}. ` +
+ `Deleting and recreating`);
}
} else if (oldKind == BookmarkSyncUtils.KINDS.LIVEMARK) {
// Similarly, if we're changing a livemark's site or feed URL, we need to
// reinsert.
shouldReinsert = yield shouldReinsertLivemark(updateInfo);
if (BookmarkSyncLog.level <= Log.Level.Debug) {
- let oldSyncId = BookmarkSyncUtils.guidToSyncId(oldBookmarkItem.guid);
- BookmarkSyncLog.debug(`updateSyncBookmark: Local ${
- oldSyncId} and remote ${
- updateInfo.syncId} livemarks have different URLs`);
+ let newSyncId = updateInfo.syncId;
+ BookmarkSyncLog.debug(`updateSyncBookmark: ` +
+ `Local ${oldSyncId} and remote ${newSyncId} ` +
+ `livemarks have different URLs`);
}
}
if (shouldReinsert) {
let newInfo = validateNewBookmark(updateInfo);
yield PlacesUtils.bookmarks.remove({
guid,
source: SOURCE_SYNC,
@@ -679,25 +681,25 @@ var updateSyncBookmark = Task.async(func
let oldId = yield PlacesUtils.promiseItemId(oldBookmarkItem.guid);
if (PlacesUtils.isRootItem(oldId)) {
throw new Error(`Cannot move Places root ${oldId}`);
}
let requestedParentGuid =
BookmarkSyncUtils.syncIdToGuid(requestedParentSyncId);
isOrphan = yield GUIDMissing(requestedParentGuid);
if (!isOrphan) {
- BookmarkSyncLog.debug(`updateSyncBookmark: Item ${
- updateInfo.syncId} is not an orphan`);
+ BookmarkSyncLog.debug(`updateSyncBookmark: Item ${updateInfo.syncId} ` +
+ `is not an orphan`);
} else {
// Don't move the item if the new parent doesn't exist. Instead, mark
// the item as an orphan. We'll annotate it with its real parent after
// updating.
- BookmarkSyncLog.trace(`updateSyncBookmark: Item ${
- updateInfo.syncId} is an orphan: could not find parent ${
- requestedParentSyncId}`);
+ BookmarkSyncLog.trace(`updateSyncBookmark: Item ${updateInfo.syncId} ` +
+ `is an orphan: could not find parent ` +
+ requestedParentSyncId);
delete updateInfo.parentSyncId;
}
} else {
// If the parent is the same, just omit it so that `update` doesn't do
// extra work.
delete updateInfo.parentSyncId;
}
}
@@ -728,18 +730,18 @@ var updateBookmarkMetadata = Task.async(
newBookmarkItem,
updateInfo) {
let itemId = yield PlacesUtils.promiseItemId(newBookmarkItem.guid);
let newItem = yield placesBookmarkToSyncBookmark(newBookmarkItem);
try {
newItem.tags = yield tagItem(newBookmarkItem, updateInfo.tags);
} catch (ex) {
- BookmarkSyncLog.warn(`updateBookmarkMetadata: Error tagging item ${
- updateInfo.syncId}`, ex);
+ BookmarkSyncLog.warn(`updateBookmarkMetadata: Error tagging item ` +
+ updateInfo.syncId, ex);
}
if (updateInfo.hasOwnProperty("keyword")) {
// Unconditionally remove the old keyword.
let entry = yield PlacesUtils.keywords.fetch({
url: oldBookmarkItem.url.href,
});
if (entry) {