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
=== modified file 'src/app/main.cpp'
--- src/app/main.cpp 2014-11-13 10:33:59 +0000
+++ src/app/main.cpp 2015-02-24 22:21:20 +0000
@@ -27,7 +27,6 @@
27#include <QtQuick/QQuickView>27#include <QtQuick/QQuickView>
28#include <QtQml/QtQml>28#include <QtQml/QtQml>
29#include <QLibrary>29#include <QLibrary>
30#include <QDir>
31#include <QCommandLineParser>30#include <QCommandLineParser>
32#include <QCommandLineOption>31#include <QCommandLineOption>
33#include <QDebug>32#include <QDebug>
@@ -141,12 +140,6 @@
141 // So if you want to change it, make sure to find all the places where it is set, not just here :D140 // So if you want to change it, make sure to find all the places where it is set, not just here :D
142 QCoreApplication::setApplicationName("com.ubuntu.reminders");141 QCoreApplication::setApplicationName("com.ubuntu.reminders");
143142
144 QDir cacheDir(QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first());
145 if (!cacheDir.exists()) {
146 qDebug() << "creating cacheDir:" << cacheDir.absolutePath();
147 cacheDir.mkpath(cacheDir.absolutePath());
148 }
149
150 qDebug() << "using main qml file from:" << qmlfile;143 qDebug() << "using main qml file from:" << qmlfile;
151 view.setSource(QUrl::fromLocalFile(qmlfile));144 view.setSource(QUrl::fromLocalFile(qmlfile));
152 view.show();145 view.show();
153146
=== modified file 'src/libqtevernote/note.cpp'
--- src/libqtevernote/note.cpp 2015-02-16 19:28:02 +0000
+++ src/libqtevernote/note.cpp 2015-02-24 22:21:20 +0000
@@ -43,7 +43,7 @@
43 m_conflicting(false)43 m_conflicting(false)
44{44{
45 setGuid(guid);45 setGuid(guid);
46 m_cacheFile.setFileName(QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first() + "/" + NotesStore::instance()->username() + "/note-" + guid + ".enml");46 m_cacheFile.setFileName(NotesStore::instance()->storageLocation() + "note-" + guid + ".enml");
4747
48 QSettings infoFile(m_infoFile, QSettings::IniFormat);48 QSettings infoFile(m_infoFile, QSettings::IniFormat);
49 m_created = infoFile.value("created").toDateTime();49 m_created = infoFile.value("created").toDateTime();
@@ -115,14 +115,14 @@
115 }115 }
116116
117 m_guid = guid;117 m_guid = guid;
118 QString newCacheFileName = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first() + "/" + NotesStore::instance()->username() + "/note-" + guid + ".enml";118 QString newCacheFileName = NotesStore::instance()->storageLocation() + "note-" + guid + ".enml";
119 if (m_cacheFile.exists()) {119 if (m_cacheFile.exists()) {
120 qDebug() << "renaming cachefile from" << m_cacheFile.fileName() << "to" << newCacheFileName;120 qDebug() << "renaming cachefile from" << m_cacheFile.fileName() << "to" << newCacheFileName;
121 m_cacheFile.rename(newCacheFileName);121 m_cacheFile.rename(newCacheFileName);
122 } else {122 } else {
123 m_cacheFile.setFileName(newCacheFileName);123 m_cacheFile.setFileName(newCacheFileName);
124 }124 }
125 m_infoFile = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first() + "/" + NotesStore::instance()->username() + "/note-" + guid + ".info";125 m_infoFile = NotesStore::instance()->storageLocation() + "note-" + guid + ".info";
126126
127 if (syncToFile) {127 if (syncToFile) {
128 syncToInfoFile();128 syncToInfoFile();
129129
=== modified file 'src/libqtevernote/notebook.cpp'
--- src/libqtevernote/notebook.cpp 2014-12-13 03:55:52 +0000
+++ src/libqtevernote/notebook.cpp 2015-02-24 22:21:20 +0000
@@ -197,7 +197,7 @@
197 }197 }
198198
199 m_guid = guid;199 m_guid = guid;
200 m_infoFile = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first() + "/" + NotesStore::instance()->username() + "/notebook-" + guid + ".info";200 m_infoFile = NotesStore::instance()->storageLocation() + "notebook-" + guid + ".info";
201201
202 if (syncToFile) {202 if (syncToFile) {
203 syncToInfoFile();203 syncToInfoFile();
204204
=== modified file 'src/libqtevernote/notesstore.cpp'
--- src/libqtevernote/notesstore.cpp 2015-02-23 18:44:26 +0000
+++ src/libqtevernote/notesstore.cpp 2015-02-24 22:21:20 +0000
@@ -48,6 +48,7 @@
48#include <QStandardPaths>48#include <QStandardPaths>
49#include <QUuid>49#include <QUuid>
50#include <QPointer>50#include <QPointer>
51#include <QDir>
5152
52NotesStore* NotesStore::s_instance = 0;53NotesStore* NotesStore::s_instance = 0;
5354
@@ -68,6 +69,12 @@
68 qRegisterMetaType<evernote::edam::Tag>("evernote::edam::Tag");69 qRegisterMetaType<evernote::edam::Tag>("evernote::edam::Tag");
6970
70 m_organizerAdapter = new OrganizerAdapter(this);71 m_organizerAdapter = new OrganizerAdapter(this);
72
73 QDir storageDir(QStandardPaths::standardLocations(QStandardPaths::DataLocation).first());
74 if (!storageDir.exists()) {
75 qDebug() << "creating storage directory:" << storageDir.absolutePath();
76 storageDir.mkpath(storageDir.absolutePath());
77 }
71}78}
7279
73NotesStore *NotesStore::instance()80NotesStore *NotesStore::instance()
@@ -98,12 +105,17 @@
98 m_username = username;105 m_username = username;
99 emit usernameChanged();106 emit usernameChanged();
100107
101 m_cacheFile = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first() + "/" + m_username + "/notes.cache";108 m_cacheFile = storageLocation() + "notes.cache";
102 qDebug() << "initialized cacheFile" << m_cacheFile;109 qDebug() << "initialized cacheFile" << m_cacheFile;
103 loadFromCacheFile();110 loadFromCacheFile();
104 }111 }
105}112}
106113
114QString NotesStore::storageLocation()
115{
116 return QStandardPaths::standardLocations(QStandardPaths::DataLocation).first() + "/" + m_username + "/";
117}
118
107void NotesStore::userStoreConnected(const QString &username)119void NotesStore::userStoreConnected(const QString &username)
108{120{
109 qDebug() << "User store connected!" << username;121 qDebug() << "User store connected!" << username;
110122
=== modified file 'src/libqtevernote/notesstore.h'
--- src/libqtevernote/notesstore.h 2014-12-16 21:01:28 +0000
+++ src/libqtevernote/notesstore.h 2015-02-24 22:21:20 +0000
@@ -98,6 +98,8 @@
98 QString username() const;98 QString username() const;
99 Q_SLOT void setUsername(const QString &username);99 Q_SLOT void setUsername(const QString &username);
100100
101 QString storageLocation();
102
101 bool loading() const;103 bool loading() const;
102 bool notebooksLoading() const;104 bool notebooksLoading() const;
103 bool tagsLoading() const;105 bool tagsLoading() const;
104106
=== modified file 'src/libqtevernote/resource.cpp'
--- src/libqtevernote/resource.cpp 2015-02-20 22:35:03 +0000
+++ src/libqtevernote/resource.cpp 2015-02-24 22:21:20 +0000
@@ -35,7 +35,7 @@
35 m_type(type)35 m_type(type)
36{36{
3737
38 m_filePath = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first() + "/" + NotesStore::instance()->username() + "/" + hash + "." + m_fileName.split('.').last();38 m_filePath = NotesStore::instance()->storageLocation() + hash + "." + m_fileName.split('.').last();
3939
40 QFile file(m_filePath);40 QFile file(m_filePath);
41 if (!data.isEmpty() && !file.exists()) {41 if (!data.isEmpty() && !file.exists()) {
@@ -51,7 +51,7 @@
5151
52bool Resource::isCached(const QString &hash)52bool Resource::isCached(const QString &hash)
53{53{
54 QDir cacheDir(QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first() + "/" + NotesStore::instance()->username());54 QDir cacheDir(NotesStore::instance()->storageLocation());
55 foreach (const QString fi, cacheDir.entryList()) {55 foreach (const QString fi, cacheDir.entryList()) {
56 if (fi.contains(hash)) {56 if (fi.contains(hash)) {
57 return true;57 return true;
@@ -84,7 +84,7 @@
84 qWarning() << "cannot determine mime type of file" << m_fileName;84 qWarning() << "cannot determine mime type of file" << m_fileName;
85 }85 }
8686
87 m_filePath = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first() + "/" + NotesStore::instance()->username() + "/" + m_hash + "." + m_fileName.split('.').last();87 m_filePath = NotesStore::instance()->storageLocation() + m_hash + "." + m_fileName.split('.').last();
8888
89 QFile copy(m_filePath);89 QFile copy(m_filePath);
90 if (!copy.exists()) {90 if (!copy.exists()) {
9191
=== modified file 'src/libqtevernote/tag.cpp'
--- src/libqtevernote/tag.cpp 2014-12-13 03:55:52 +0000
+++ src/libqtevernote/tag.cpp 2015-02-24 22:21:20 +0000
@@ -69,7 +69,7 @@
69 }69 }
7070
71 m_guid = guid;71 m_guid = guid;
72 m_infoFile = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first() + "/" + NotesStore::instance()->username() + "/tag-" + guid + ".info";72 m_infoFile = NotesStore::instance()->storageLocation() + "tag-" + guid + ".info";
7373
74 if (syncToFile) {74 if (syncToFile) {
75 syncToInfoFile();75 syncToInfoFile();
7676
=== modified file 'src/libqtevernote/utils/enmldocument.cpp'
--- src/libqtevernote/utils/enmldocument.cpp 2015-02-16 21:57:16 +0000
+++ src/libqtevernote/utils/enmldocument.cpp 2015-02-24 22:21:20 +0000
@@ -159,7 +159,7 @@
159 if (type == TypeRichText) {159 if (type == TypeRichText) {
160 writer.writeAttribute("src", composeMediaTypeUrl(mediaType, noteGuid, hash));160 writer.writeAttribute("src", composeMediaTypeUrl(mediaType, noteGuid, hash));
161 } else if (type == TypeHtml) {161 } else if (type == TypeHtml) {
162 QString imagePath = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first() + "/" + NotesStore::instance()->username() + "/" + hash + "." + mediaType.split('/').last();162 QString imagePath = NotesStore::instance()->storageLocation() + hash + "." + mediaType.split('/').last();
163 writer.writeAttribute("src", imagePath);163 writer.writeAttribute("src", imagePath);
164 writer.writeAttribute("id", "en-attachment/" + hash + "/" + mediaType);164 writer.writeAttribute("id", "en-attachment/" + hash + "/" + mediaType);
165 }165 }

Subscribers

People subscribed via source and target branches