From 82ca7ebb9c24fef6f1860eeca9577d998af03c7f Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 13 Jun 2016 14:39:57 +0200 Subject: Implemented maildir mail moves and got it to pass tests again --- examples/maildirresource/libmaildir/maildir.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'examples/maildirresource/libmaildir') diff --git a/examples/maildirresource/libmaildir/maildir.cpp b/examples/maildirresource/libmaildir/maildir.cpp index c55e00e..de704f2 100644 --- a/examples/maildirresource/libmaildir/maildir.cpp +++ b/examples/maildirresource/libmaildir/maildir.cpp @@ -141,6 +141,10 @@ public: QString findRealKey(const QString& key) const { + if (key.isEmpty()) { + qWarning() << "Empty key: " << key; + return key; + } // KeyCache* keyCache = KeyCache::self(); // if (keyCache->isNewKey(path, key)) { if (QFile::exists(path + QString::fromLatin1("/new/") + key)) { @@ -670,7 +674,7 @@ QString Maildir::addEntry(const QByteArray& data) do { uniqueKey = createUniqueFileName() + d->hostName; key = d->path + QLatin1String("/tmp/") + uniqueKey; - finalKey = d->path + QLatin1String("/new/") + uniqueKey; + finalKey = d->path + QLatin1String("/cur/") + uniqueKey; curKey = d->path + QLatin1String("/cur/") + uniqueKey; } while (QFile::exists(key) || QFile::exists(finalKey) || QFile::exists(curKey)); @@ -911,7 +915,7 @@ QString Maildir::moveEntryTo(const QString &key, const Maildir &destination) } QFile f(realKey); // ### is this safe regarding the maildir locking scheme? - const QString targetKey = destination.path() + QDir::separator() + QLatin1String("new") + QDir::separator() + key; + const QString targetKey = destination.path() + QDir::separator() + QLatin1String("cur") + QDir::separator() + key; if (!f.rename(targetKey)) { qDebug() << "Failed to rename" << realKey << "to" << targetKey << "! Error: " << f.errorString();; d->lastError = f.errorString(); -- cgit v1.2.3