зеркало из https://github.com/mozilla/pjs.git
Bug 731024 - Part 5: Safer handling of deleted items. r=nalexander
This commit is contained in:
Родитель
ea9c21b9c6
Коммит
fba887b0ff
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче