[contacts] Fix ContactCreateJob with a photo
ClosedPublic

Authored by poboiko on Mar 21 2020, 9:45 AM.

Details

Summary

When we run ContactCreateJob, the UID of a contact is not yet known.
We can only add a photo only after we receive a reply from main create job.

Also, since we also don't want the following race condition to trigger:

  1. Contact1 create request
  2. Contact1 reply, Photo1 change request, Contact2 create request
  3. Contact2 reply, Photo2 change request
  4. Photo1 reply (here both currentContact and lastContact is Contact2)
  5. Photo2 reply

we only go for next contact after the previous has been fully procesed:

  1. Contact1 create request
  2. Contact1 reply, Photo1 change request
  3. Photo1 reply, Contact2 create request
  4. Contact2 reply, Photo2 change request
  5. Photo2 reply
Test Plan

Without patch:

  1. Create a contact with photo inside KAddressBook
  2. Check Web UI: no photo is set, sometimes bunch of contacts get created (?)

With patch:

  1. Observe a single contact with a proper photo being set

Diff Detail

Repository
R477 KGAPI Library
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
poboiko created this revision.Mar 21 2020, 9:45 AM
Restricted Application added a project: KDE PIM. · View Herald TranscriptMar 21 2020, 9:45 AM
poboiko requested review of this revision.Mar 21 2020, 9:45 AM
dvratil requested changes to this revision.Mar 21 2020, 12:23 PM

Looks good, thanks. Just a small thing, same as in the other review - move the code to a dedicated function please.

src/contacts/contactcreatejob.cpp
153–165

Please the code to a dedicated function, please.

This revision now requires changes to proceed.Mar 21 2020, 12:23 PM
poboiko updated this revision to Diff 78163.Mar 21 2020, 1:46 PM

Move code setting the picture to a dedicated function

dvratil accepted this revision.Mar 21 2020, 2:18 PM

Please fix the small nitpick before committing. Otherwise good to go. Thanks!

src/contacts/contactcreatejob.cpp
153

const bool (or just drop the variable altogether, your call)

This revision is now accepted and ready to land.Mar 21 2020, 2:18 PM
poboiko updated this revision to Diff 78172.Mar 21 2020, 4:14 PM

Drop the unnecessary variable

This revision was automatically updated to reflect the committed changes.