Merge lp:~mzanetti/reminders-app/needsContentSync into lp:reminders-app

Proposed by Michael Zanetti
Status: Merged
Approved by: Riccardo Padovani
Approved revision: 359
Merged at revision: 359
Proposed branch: lp:~mzanetti/reminders-app/needsContentSync
Merge into: lp:reminders-app
Prerequisite: lp:~mzanetti/reminders-app/better-reset-connection
Diff against target: 197 lines (+58/-30)
3 files modified
src/libqtevernote/jobs/savenotejob.cpp (+32/-29)
src/libqtevernote/note.cpp (+24/-1)
src/libqtevernote/note.h (+2/-0)
To merge this branch: bzr merge lp:~mzanetti/reminders-app/needsContentSync
Reviewer Review Type Date Requested Status
Riccardo Padovani Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+251333@code.launchpad.net

Commit message

Don't send the note content to the server if it hasn't changed.

This avoids long saving times for notes with big content/attachment when only changing it's reminder or tags.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Riccardo Padovani (rpadovani) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/libqtevernote/jobs/savenotejob.cpp'
2--- src/libqtevernote/jobs/savenotejob.cpp 2014-12-16 21:01:28 +0000
3+++ src/libqtevernote/jobs/savenotejob.cpp 2015-02-27 22:17:17 +0000
4@@ -78,10 +78,6 @@
5 note.tagGuids = tags;
6 note.__isset.tagGuids = true;
7
8- note.content = m_note->enmlContent().toStdString();
9- note.__isset.content = true;
10- note.contentLength = m_note->enmlContent().length();
11-
12 note.__isset.attributes = true;
13 note.attributes.reminderOrder = m_note->reminderOrder();
14 note.attributes.__isset.reminderOrder = true;
15@@ -90,32 +86,39 @@
16 note.attributes.reminderDoneTime = m_note->reminderDoneTime().toMSecsSinceEpoch();
17 note.attributes.__isset.reminderDoneTime = true;
18
19- note.resources.clear();
20- foreach (Resource *resource, m_note->resources()) {
21- evernote::edam::Resource evResource;
22- evResource.noteGuid = m_note->guid().toStdString();
23- evResource.__isset.noteGuid = true;
24- evResource.mime = resource->type().toStdString();
25- evResource.__isset.mime = true;
26-
27- evResource.data.bodyHash = resource->hash().toStdString();
28- evResource.data.__isset.bodyHash = true;
29-
30- QByteArray data = resource->data();
31- evResource.data.body.assign(data.data(), data.length());
32- evResource.data.__isset.body = true;
33-
34- evResource.data.size = data.length();
35- evResource.data.__isset.size = true;
36- evResource.__isset.data = true;
37-
38- evResource.attributes.fileName = resource->fileName().toStdString();
39- evResource.attributes.__isset.fileName = true;
40- evResource.__isset.attributes = true;
41-
42- note.resources.push_back(evResource);
43+ qDebug() << "*** needs content sync" << m_note->needsContentSync();
44+ if (m_note->needsContentSync()) {
45+ note.content = m_note->enmlContent().toStdString();
46+ note.__isset.content = true;
47+ note.contentLength = m_note->enmlContent().length();
48+
49+ note.resources.clear();
50+ foreach (Resource *resource, m_note->resources()) {
51+ evernote::edam::Resource evResource;
52+ evResource.noteGuid = m_note->guid().toStdString();
53+ evResource.__isset.noteGuid = true;
54+ evResource.mime = resource->type().toStdString();
55+ evResource.__isset.mime = true;
56+
57+ evResource.data.bodyHash = resource->hash().toStdString();
58+ evResource.data.__isset.bodyHash = true;
59+
60+ QByteArray data = resource->data();
61+ evResource.data.body.assign(data.data(), data.length());
62+ evResource.data.__isset.body = true;
63+
64+ evResource.data.size = data.length();
65+ evResource.data.__isset.size = true;
66+ evResource.__isset.data = true;
67+
68+ evResource.attributes.fileName = resource->fileName().toStdString();
69+ evResource.attributes.__isset.fileName = true;
70+ evResource.__isset.attributes = true;
71+
72+ note.resources.push_back(evResource);
73+ }
74+ note.__isset.resources = true;
75 }
76- note.__isset.resources = true;
77 }
78
79 // In some error cases it may happen that the resultNote is not filled in. Make sure we have at least the guid
80
81=== modified file 'src/libqtevernote/note.cpp'
82--- src/libqtevernote/note.cpp 2015-02-27 11:46:17 +0000
83+++ src/libqtevernote/note.cpp 2015-02-27 22:17:17 +0000
84@@ -41,7 +41,8 @@
85 m_loadingHighPriority(false),
86 m_loaded(false),
87 m_syncError(false),
88- m_conflicting(false)
89+ m_conflicting(false),
90+ m_needsContentSync(false)
91 {
92 setGuid(guid);
93 m_cacheFile.setFileName(NotesStore::instance()->storageLocation() + "note-" + guid + ".enml");
94@@ -58,6 +59,7 @@
95 m_deleted = infoFile.value("deleted").toBool();
96 m_tagline = infoFile.value("tagline").toString();
97 m_lastSyncedSequenceNumber = infoFile.value("lastSyncedSequenceNumber", 0).toUInt();
98+ m_needsContentSync = infoFile.value("needsContentSync", false).toBool();
99 m_synced = m_lastSyncedSequenceNumber == m_updateSequenceNumber;
100
101 infoFile.beginGroup("resources");
102@@ -254,6 +256,10 @@
103 m_content.setEnml(enmlContent);
104 m_tagline = m_content.toPlaintext().left(100);
105 emit contentChanged();
106+
107+ if (m_loaded) {
108+ m_needsContentSync = true;
109+ }
110 }
111 m_loaded = true;
112 }
113@@ -278,6 +284,8 @@
114 m_content.setRichText(richTextContent);
115 m_tagline = m_content.toPlaintext().left(100);
116 emit contentChanged();
117+
118+ m_needsContentSync = true;
119 }
120 }
121
122@@ -454,6 +462,9 @@
123 m_updateSequenceNumber = updateSequenceNumber;
124
125 m_synced = m_updateSequenceNumber == m_lastSyncedSequenceNumber;
126+ if (m_synced) {
127+ m_needsContentSync = false;
128+ }
129 emit syncedChanged();
130 }
131 }
132@@ -469,6 +480,9 @@
133 m_lastSyncedSequenceNumber = lastSyncedSequenceNumber;
134
135 m_synced = m_updateSequenceNumber == m_lastSyncedSequenceNumber;
136+ if (m_synced) {
137+ m_needsContentSync = false;
138+ }
139 emit syncedChanged();
140 }
141 }
142@@ -544,6 +558,8 @@
143 // TODO: If the app should be extended to allow attaching other files, and we somehow
144 // can browse to unconfined files, this needs to be made conditional to not delete those files!
145 importedFile.remove();
146+
147+ m_needsContentSync = true;
148 }
149
150 void Note::format(int startPos, int endPos, TextFormat::Format format)
151@@ -579,6 +595,7 @@
152 foreach (Resource *resource, m_resources) {
153 note->addResource(resource->data(), resource->hash(), resource->fileName(), resource->type());
154 }
155+ note->m_needsContentSync = m_needsContentSync;
156
157 return note;
158 }
159@@ -631,6 +648,7 @@
160 infoFile.setValue("created", m_created);
161 infoFile.setValue("title", m_title);
162 infoFile.setValue("updated", m_updated);
163+ infoFile.setValue("needsContentSync", m_needsContentSync);
164
165 infoFile.setValue("notebookGuid", m_notebookGuid);
166 infoFile.setValue("tagGuids", m_tagGuids);
167@@ -708,6 +726,11 @@
168 return m_conflicting;
169 }
170
171+bool Note::needsContentSync() const
172+{
173+ return m_needsContentSync;
174+}
175+
176 void Note::setConflicting(bool conflicting)
177 {
178 if (m_conflicting != conflicting) {
179
180=== modified file 'src/libqtevernote/note.h'
181--- src/libqtevernote/note.h 2015-02-27 11:46:17 +0000
182+++ src/libqtevernote/note.h 2015-02-27 22:17:17 +0000
183@@ -147,6 +147,7 @@
184 bool synced() const;
185 bool syncError() const;
186 bool conflicting() const;
187+ bool needsContentSync() const;
188
189 QStringList resourceUrls() const;
190 Q_INVOKABLE Resource* resource(const QString &hash);
191@@ -229,6 +230,7 @@
192 bool m_loadingHighPriority;
193 mutable bool m_loaded;
194 bool m_synced;
195+ bool m_needsContentSync;
196 bool m_syncError;
197 bool m_conflicting;
198

Subscribers

People subscribed via source and target branches