Bug 731024 - Part 5: Safer handling of deleted items. r=nalexander

This commit is contained in:
Richard Newman 2012-03-27 10:47:26 -07:00
Родитель ea9c21b9c6
Коммит fba887b0ff
3 изменённых файлов: 22 добавлений и 1 удалений

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

@ -189,6 +189,13 @@ public class AndroidBrowserBookmarksDataAccessor extends AndroidBrowserRepositor
protected ContentValues getContentValues(Record record) {
BookmarkRecord rec = (BookmarkRecord) record;
if (rec.deleted) {
ContentValues cv = new ContentValues();
cv.put(BrowserContract.SyncColumns.GUID, rec.guid);
cv.put(BrowserContract.Bookmarks.IS_DELETED, 1);
return cv;
}
final int recordType = BrowserContractHelpers.typeCodeForString(rec.type);
if (recordType == -1) {
throw new IllegalStateException("Unexpected record type " + rec.type);

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

@ -566,6 +566,11 @@ public class AndroidBrowserBookmarksRepositorySession extends AndroidBrowserRepo
@Override
protected Record prepareRecord(Record record) {
if (record.deleted) {
Logger.debug(LOG_TAG, "No need to prepare deleted record " + record.guid);
return record;
}
BookmarkRecord bmk = (BookmarkRecord) record;
if (!isSpecialRecord(record)) {

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

@ -456,7 +456,16 @@ public abstract class AndroidBrowserRepositorySession extends StoreTrackingRepos
}
// TODO: pass in timestamps?
Logger.debug(LOG_TAG, "Replacing existing " + existingRecord.guid + " with record " + toStore.guid);
// This section of code will only run if the incoming record is not
// marked as deleted, so we never want to just drop ours from the database:
// we need to upload it later.
// Allowing deleted items to propagate through `replace` allows normal
// logging and side-effects to occur, and is no more expensive than simply
// bumping the modified time.
Logger.debug(LOG_TAG, "Replacing existing " + existingRecord.guid +
(toStore.deleted ? " with deleted record " : " with record ") +
toStore.guid);
Record replaced = replace(toStore, existingRecord);
// Note that we don't track records here; deciding that is the job