Merge lp:~mzanetti/reminders-app/cache-to-storage into lp:reminders-app

Proposed by Michael Zanetti
Status: Merged
Approved by: Riccardo Padovani
Approved revision: 350
Merged at revision: 350
Proposed branch: lp:~mzanetti/reminders-app/cache-to-storage
Merge into: lp:reminders-app
Diff against target: 181 lines (+24/-17)
8 files modified
src/app/main.cpp (+0/-7)
src/libqtevernote/note.cpp (+3/-3)
src/libqtevernote/notebook.cpp (+1/-1)
src/libqtevernote/notesstore.cpp (+13/-1)
src/libqtevernote/notesstore.h (+2/-0)
src/libqtevernote/resource.cpp (+3/-3)
src/libqtevernote/tag.cpp (+1/-1)
src/libqtevernote/utils/enmldocument.cpp (+1/-1)
To merge this branch: bzr merge lp:~mzanetti/reminders-app/cache-to-storage
Reviewer Review Type Date Requested Status
Riccardo Padovani Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+250824@code.launchpad.net

Commit message

move storage from ~/.cache to ~/.local/share

now with offline mode, this isn't really just a cache any more

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 :

storageLocation() has already the final slash, you don't need to add in the code :-)
See inline

review: Needs Fixing
350. By Michael Zanetti

drop redundant /

Revision history for this message
Riccardo Padovani (rpadovani) wrote :

Now looks perfect :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/main.cpp'
2--- src/app/main.cpp 2014-11-13 10:33:59 +0000
3+++ src/app/main.cpp 2015-02-24 22:21:20 +0000
4@@ -27,7 +27,6 @@
5 #include <QtQuick/QQuickView>
6 #include <QtQml/QtQml>
7 #include <QLibrary>
8-#include <QDir>
9 #include <QCommandLineParser>
10 #include <QCommandLineOption>
11 #include <QDebug>
12@@ -141,12 +140,6 @@
13 // So if you want to change it, make sure to find all the places where it is set, not just here :D
14 QCoreApplication::setApplicationName("com.ubuntu.reminders");
15
16- QDir cacheDir(QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first());
17- if (!cacheDir.exists()) {
18- qDebug() << "creating cacheDir:" << cacheDir.absolutePath();
19- cacheDir.mkpath(cacheDir.absolutePath());
20- }
21-
22 qDebug() << "using main qml file from:" << qmlfile;
23 view.setSource(QUrl::fromLocalFile(qmlfile));
24 view.show();
25
26=== modified file 'src/libqtevernote/note.cpp'
27--- src/libqtevernote/note.cpp 2015-02-16 19:28:02 +0000
28+++ src/libqtevernote/note.cpp 2015-02-24 22:21:20 +0000
29@@ -43,7 +43,7 @@
30 m_conflicting(false)
31 {
32 setGuid(guid);
33- m_cacheFile.setFileName(QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first() + "/" + NotesStore::instance()->username() + "/note-" + guid + ".enml");
34+ m_cacheFile.setFileName(NotesStore::instance()->storageLocation() + "note-" + guid + ".enml");
35
36 QSettings infoFile(m_infoFile, QSettings::IniFormat);
37 m_created = infoFile.value("created").toDateTime();
38@@ -115,14 +115,14 @@
39 }
40
41 m_guid = guid;
42- QString newCacheFileName = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first() + "/" + NotesStore::instance()->username() + "/note-" + guid + ".enml";
43+ QString newCacheFileName = NotesStore::instance()->storageLocation() + "note-" + guid + ".enml";
44 if (m_cacheFile.exists()) {
45 qDebug() << "renaming cachefile from" << m_cacheFile.fileName() << "to" << newCacheFileName;
46 m_cacheFile.rename(newCacheFileName);
47 } else {
48 m_cacheFile.setFileName(newCacheFileName);
49 }
50- m_infoFile = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first() + "/" + NotesStore::instance()->username() + "/note-" + guid + ".info";
51+ m_infoFile = NotesStore::instance()->storageLocation() + "note-" + guid + ".info";
52
53 if (syncToFile) {
54 syncToInfoFile();
55
56=== modified file 'src/libqtevernote/notebook.cpp'
57--- src/libqtevernote/notebook.cpp 2014-12-13 03:55:52 +0000
58+++ src/libqtevernote/notebook.cpp 2015-02-24 22:21:20 +0000
59@@ -197,7 +197,7 @@
60 }
61
62 m_guid = guid;
63- m_infoFile = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first() + "/" + NotesStore::instance()->username() + "/notebook-" + guid + ".info";
64+ m_infoFile = NotesStore::instance()->storageLocation() + "notebook-" + guid + ".info";
65
66 if (syncToFile) {
67 syncToInfoFile();
68
69=== modified file 'src/libqtevernote/notesstore.cpp'
70--- src/libqtevernote/notesstore.cpp 2015-02-23 18:44:26 +0000
71+++ src/libqtevernote/notesstore.cpp 2015-02-24 22:21:20 +0000
72@@ -48,6 +48,7 @@
73 #include <QStandardPaths>
74 #include <QUuid>
75 #include <QPointer>
76+#include <QDir>
77
78 NotesStore* NotesStore::s_instance = 0;
79
80@@ -68,6 +69,12 @@
81 qRegisterMetaType<evernote::edam::Tag>("evernote::edam::Tag");
82
83 m_organizerAdapter = new OrganizerAdapter(this);
84+
85+ QDir storageDir(QStandardPaths::standardLocations(QStandardPaths::DataLocation).first());
86+ if (!storageDir.exists()) {
87+ qDebug() << "creating storage directory:" << storageDir.absolutePath();
88+ storageDir.mkpath(storageDir.absolutePath());
89+ }
90 }
91
92 NotesStore *NotesStore::instance()
93@@ -98,12 +105,17 @@
94 m_username = username;
95 emit usernameChanged();
96
97- m_cacheFile = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first() + "/" + m_username + "/notes.cache";
98+ m_cacheFile = storageLocation() + "notes.cache";
99 qDebug() << "initialized cacheFile" << m_cacheFile;
100 loadFromCacheFile();
101 }
102 }
103
104+QString NotesStore::storageLocation()
105+{
106+ return QStandardPaths::standardLocations(QStandardPaths::DataLocation).first() + "/" + m_username + "/";
107+}
108+
109 void NotesStore::userStoreConnected(const QString &username)
110 {
111 qDebug() << "User store connected!" << username;
112
113=== modified file 'src/libqtevernote/notesstore.h'
114--- src/libqtevernote/notesstore.h 2014-12-16 21:01:28 +0000
115+++ src/libqtevernote/notesstore.h 2015-02-24 22:21:20 +0000
116@@ -98,6 +98,8 @@
117 QString username() const;
118 Q_SLOT void setUsername(const QString &username);
119
120+ QString storageLocation();
121+
122 bool loading() const;
123 bool notebooksLoading() const;
124 bool tagsLoading() const;
125
126=== modified file 'src/libqtevernote/resource.cpp'
127--- src/libqtevernote/resource.cpp 2015-02-20 22:35:03 +0000
128+++ src/libqtevernote/resource.cpp 2015-02-24 22:21:20 +0000
129@@ -35,7 +35,7 @@
130 m_type(type)
131 {
132
133- m_filePath = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first() + "/" + NotesStore::instance()->username() + "/" + hash + "." + m_fileName.split('.').last();
134+ m_filePath = NotesStore::instance()->storageLocation() + hash + "." + m_fileName.split('.').last();
135
136 QFile file(m_filePath);
137 if (!data.isEmpty() && !file.exists()) {
138@@ -51,7 +51,7 @@
139
140 bool Resource::isCached(const QString &hash)
141 {
142- QDir cacheDir(QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first() + "/" + NotesStore::instance()->username());
143+ QDir cacheDir(NotesStore::instance()->storageLocation());
144 foreach (const QString fi, cacheDir.entryList()) {
145 if (fi.contains(hash)) {
146 return true;
147@@ -84,7 +84,7 @@
148 qWarning() << "cannot determine mime type of file" << m_fileName;
149 }
150
151- m_filePath = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first() + "/" + NotesStore::instance()->username() + "/" + m_hash + "." + m_fileName.split('.').last();
152+ m_filePath = NotesStore::instance()->storageLocation() + m_hash + "." + m_fileName.split('.').last();
153
154 QFile copy(m_filePath);
155 if (!copy.exists()) {
156
157=== modified file 'src/libqtevernote/tag.cpp'
158--- src/libqtevernote/tag.cpp 2014-12-13 03:55:52 +0000
159+++ src/libqtevernote/tag.cpp 2015-02-24 22:21:20 +0000
160@@ -69,7 +69,7 @@
161 }
162
163 m_guid = guid;
164- m_infoFile = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first() + "/" + NotesStore::instance()->username() + "/tag-" + guid + ".info";
165+ m_infoFile = NotesStore::instance()->storageLocation() + "tag-" + guid + ".info";
166
167 if (syncToFile) {
168 syncToInfoFile();
169
170=== modified file 'src/libqtevernote/utils/enmldocument.cpp'
171--- src/libqtevernote/utils/enmldocument.cpp 2015-02-16 21:57:16 +0000
172+++ src/libqtevernote/utils/enmldocument.cpp 2015-02-24 22:21:20 +0000
173@@ -159,7 +159,7 @@
174 if (type == TypeRichText) {
175 writer.writeAttribute("src", composeMediaTypeUrl(mediaType, noteGuid, hash));
176 } else if (type == TypeHtml) {
177- QString imagePath = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first() + "/" + NotesStore::instance()->username() + "/" + hash + "." + mediaType.split('/').last();
178+ QString imagePath = NotesStore::instance()->storageLocation() + hash + "." + mediaType.split('/').last();
179 writer.writeAttribute("src", imagePath);
180 writer.writeAttribute("id", "en-attachment/" + hash + "/" + mediaType);
181 }

Subscribers

People subscribed via source and target branches