Synchronize remote notes with the current database
| 563 | |
| 564 | // Synchronize remote notes with the current database |
| 565 | void SyncRunner::syncRemoteNotes(QList<Note> notes, qint32 account) { |
| 566 | QLOG_TRACE() << "Entering SyncRunner::syncRemoteNotes"; |
| 567 | NoteTable noteTable(db); |
| 568 | NotebookTable bookTable(db); |
| 569 | |
| 570 | for (int i=0; i<notes.size() && keepRunning; i++) { |
| 571 | Note t = notes[i]; |
| 572 | qint32 lid = noteTable.getLid(t.guid); |
| 573 | if (lid > 0) { |
| 574 | // Find out if it is a conflicting change |
| 575 | if (noteTable.isDirty(lid)) { |
| 576 | qint32 newLid = noteTable.duplicateNote(lid); |
| 577 | qint32 conflictNotebook = bookTable.getConflictNotebook(); |
| 578 | noteTable.updateNotebook(newLid, conflictNotebook, true); |
| 579 | if (!finalSync) |
| 580 | emit noteUpdated(newLid); |
| 581 | } |
| 582 | noteTable.sync(lid, notes.at(i), account); |
| 583 | } else { |
| 584 | noteTable.sync(t, account); |
| 585 | lid = noteTable.getLid(t.guid); |
| 586 | } |
| 587 | // Remove it from the cache (if it exists) |
| 588 | if (global.cache.contains(lid)) { |
| 589 | delete global.cache[lid]; |
| 590 | global.cache.remove(lid); |
| 591 | } |
| 592 | if (!finalSync) |
| 593 | emit noteUpdated(lid); |
| 594 | } |
| 595 | |
| 596 | QLOG_TRACE() << "Leaving SyncRunner::syncRemoteNotes"; |
| 597 | } |
| 598 | |
| 599 | |
| 600 |
nothing calls this directly
no test coverage detected