MCPcopy Create free account
hub / github.com/baumgarr/nixnote2 / syncRemoteNotes

Method syncRemoteNotes

threads/syncrunner.cpp:565–597  ·  view source on GitHub ↗

Synchronize remote notes with the current database

Source from the content-addressed store, hash-verified

563
564// Synchronize remote notes with the current database
565void 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

Callers

nothing calls this directly

Calls 7

duplicateNoteMethod · 0.80
getConflictNotebookMethod · 0.80
removeMethod · 0.80
getLidMethod · 0.45
isDirtyMethod · 0.45
updateNotebookMethod · 0.45
syncMethod · 0.45

Tested by

no test coverage detected