Bug 709432 - don't unconditionally replace inserted record GUIDs. r=blassey, a=blassey (Java-only)

This commit is contained in:
Richard Newman 2011-12-11 22:24:40 -08:00
parent 17ae42799a
commit c2b5331b98

View File

@ -479,8 +479,10 @@ public class BrowserProvider extends ContentProvider {
values.put(Bookmarks.DATE_CREATED, now);
values.put(Bookmarks.DATE_MODIFIED, now);
// Generate GUID for new bookmark
values.put(Bookmarks.GUID, UUID.randomUUID().toString());
// Generate GUID for new bookmark. Don't override specified GUIDs.
if (!values.containsKey(Bookmarks.GUID)) {
values.put(Bookmarks.GUID, UUID.randomUUID().toString());
}
if (!values.containsKey(Bookmarks.POSITION)) {
Log.d(LOGTAG, "Inserting bookmark with no position for URI");
@ -509,8 +511,10 @@ public class BrowserProvider extends ContentProvider {
values.put(History.DATE_CREATED, now);
values.put(History.DATE_MODIFIED, now);
// Generate GUID for new history entry
values.put(History.GUID, UUID.randomUUID().toString());
// Generate GUID for new history entry. Don't override specified GUIDs.
if (!values.containsKey(History.GUID)) {
values.put(History.GUID, UUID.randomUUID().toString());
}
String url = values.getAsString(History.URL);
@ -884,8 +888,10 @@ public class BrowserProvider extends ContentProvider {
int updated = db.update(TABLE_IMAGES, values, selection, selectionArgs);
if (updated == 0) {
// Generate GUID for new image
values.put(Images.GUID, UUID.randomUUID().toString());
// Generate GUID for new image, if one is not already provided.
if (!values.containsKey(Images.GUID)) {
values.put(Images.GUID, UUID.randomUUID().toString());
}
values.put(Images.DATE_CREATED, now);
values.put(Images.DATE_MODIFIED, now);
@ -924,4 +930,4 @@ public class BrowserProvider extends ContentProvider {
return db.delete(TABLE_IMAGES, selection, null);
}
}
}