1
0
mirror of https://github.com/etesync/android synced 2024-11-15 20:38:58 +00:00

Fix a race condition when preparing dirty.

This commit is contained in:
Tom Hacohen 2017-02-16 19:30:36 +00:00
parent dd6ce617cc
commit ef850822de

View File

@ -325,9 +325,10 @@ abstract public class SyncManager {
/** /**
*/ */
protected void prepareLocal() throws CalendarStorageException, ContactsStorageException, FileNotFoundException { protected void prepareLocal() throws CalendarStorageException, ContactsStorageException, FileNotFoundException {
prepareDirty();
localDeleted = processLocallyDeleted(); localDeleted = processLocallyDeleted();
localDirty = localCollection.getDirty(); localDirty = localCollection.getDirty();
// This is done after fetching the local dirty so all the ones we are using will be prepared
prepareDirty();
remoteCTag = localCollection.getCTag(); remoteCTag = localCollection.getCTag();
} }
@ -360,9 +361,12 @@ abstract public class SyncManager {
} }
protected void prepareDirty() throws CalendarStorageException, ContactsStorageException { protected void prepareDirty() throws CalendarStorageException, ContactsStorageException {
// assign file names and UIDs to new contacts so that we can use the file name as an index // assign file names and UIDs to new entries
App.log.info("Looking for contacts/groups without file name"); App.log.info("Looking for local entries without a uuid");
for (LocalResource local : localCollection.getWithoutFileName()) { for (LocalResource local : localDirty) {
if (local.getUuid() != null) {
continue;
}
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
App.log.fine("Found local record #" + local.getId() + " without file name; assigning file name/UID based on " + uuid); App.log.fine("Found local record #" + local.getId() + " without file name; assigning file name/UID based on " + uuid);
local.updateFileNameAndUID(uuid); local.updateFileNameAndUID(uuid);