diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-05 17:33:08 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-02-05 18:14:43 +0100 |
commit | 47bfba0d9152a1f7f689d7936b107b1a899a0b76 (patch) | |
tree | d3097b1da7bc87984bd7fdffbf803ed682e95fcc /examples/maildirresource/libmaildir/maildir.cpp | |
parent | b9a79ed514e7ab6bab0d6dedfcb9a78387d2b7c1 (diff) | |
download | sink-47bfba0d9152a1f7f689d7936b107b1a899a0b76.tar.gz sink-47bfba0d9152a1f7f689d7936b107b1a899a0b76.zip |
Use property transformation for the mimeMessage
The filepath changes with every flag change. It is thus easier to only
store a limited path that remains stable, and figure out the rest as
the property is requested (we'll have to translate it anyways once we
the file handoff protocol is implemented).
The reason why we don't update the mimeMessage path on every
modification is because we move the message during change replay,
and not while storing the modification in the db. This would lead to
the message-path on disk not correspond to what is in the db for some
time.
Diffstat (limited to 'examples/maildirresource/libmaildir/maildir.cpp')
-rw-r--r-- | examples/maildirresource/libmaildir/maildir.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/maildirresource/libmaildir/maildir.cpp b/examples/maildirresource/libmaildir/maildir.cpp index 0057b26..59e7e5c 100644 --- a/examples/maildirresource/libmaildir/maildir.cpp +++ b/examples/maildirresource/libmaildir/maildir.cpp | |||
@@ -177,6 +177,13 @@ public: | |||
177 | return realKey; | 177 | return realKey; |
178 | } | 178 | } |
179 | 179 | ||
180 | static QString stripFlags(const QString& key) | ||
181 | { | ||
182 | const QRegExp rx = *(statusSeparatorRx()); | ||
183 | const int index = key.indexOf(rx); | ||
184 | return key.mid(0, index); | ||
185 | } | ||
186 | |||
180 | static QString subDirNameForFolderName(const QString &folderName) | 187 | static QString subDirNameForFolderName(const QString &folderName) |
181 | { | 188 | { |
182 | return QString::fromLatin1(".%1.directory").arg(folderName); | 189 | return QString::fromLatin1(".%1.directory").arg(folderName); |
@@ -559,6 +566,19 @@ QDateTime Maildir::lastModified(const QString& key) const | |||
559 | return info.lastModified(); | 566 | return info.lastModified(); |
560 | } | 567 | } |
561 | 568 | ||
569 | QString Maildir::getKeyFromFile(const QString& file) | ||
570 | { | ||
571 | return Maildir::Private::stripFlags(file.split('/').last()); | ||
572 | } | ||
573 | |||
574 | QString Maildir::getDirectoryFromFile( const QString& file ) | ||
575 | { | ||
576 | auto parts = file.split('/'); | ||
577 | parts.removeLast(); //File | ||
578 | parts.removeLast(); //cur/new/tmp | ||
579 | return parts.join('/') + "/"; | ||
580 | } | ||
581 | |||
562 | QByteArray Maildir::readEntryHeadersFromFile(const QString& file) | 582 | QByteArray Maildir::readEntryHeadersFromFile(const QString& file) |
563 | { | 583 | { |
564 | QByteArray result; | 584 | QByteArray result; |