From 47bfba0d9152a1f7f689d7936b107b1a899a0b76 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 5 Feb 2016 17:33:08 +0100 Subject: 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. --- examples/maildirresource/libmaildir/maildir.cpp | 20 ++++++++++++++++++++ examples/maildirresource/libmaildir/maildir.h | 13 +++++++++++++ 2 files changed, 33 insertions(+) (limited to 'examples/maildirresource/libmaildir') 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: return realKey; } + static QString stripFlags(const QString& key) + { + const QRegExp rx = *(statusSeparatorRx()); + const int index = key.indexOf(rx); + return key.mid(0, index); + } + static QString subDirNameForFolderName(const QString &folderName) { return QString::fromLatin1(".%1.directory").arg(folderName); @@ -559,6 +566,19 @@ QDateTime Maildir::lastModified(const QString& key) const return info.lastModified(); } +QString Maildir::getKeyFromFile(const QString& file) +{ + return Maildir::Private::stripFlags(file.split('/').last()); +} + +QString Maildir::getDirectoryFromFile( const QString& file ) +{ + auto parts = file.split('/'); + parts.removeLast(); //File + parts.removeLast(); //cur/new/tmp + return parts.join('/') + "/"; +} + QByteArray Maildir::readEntryHeadersFromFile(const QString& file) { QByteArray result; diff --git a/examples/maildirresource/libmaildir/maildir.h b/examples/maildirresource/libmaildir/maildir.h index 5936515..6c68656 100644 --- a/examples/maildirresource/libmaildir/maildir.h +++ b/examples/maildirresource/libmaildir/maildir.h @@ -262,6 +262,19 @@ public: querying the last error string. */ QString lastError() const; + /** + * Returns the key from the file identified by the full path @param file. + */ + static QString getKeyFromFile( const QString& file ); + + /** + * Returns the directory from a file. + * + * Strips key and new/cur/tmp. + * The returned path is ended with a trailing slash. + */ + static QString getDirectoryFromFile( const QString& file ); + private: void swap( const Maildir& ); class Private; -- cgit v1.2.3