diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-12-17 13:11:28 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-12-17 13:11:28 +0100 |
commit | 4a6f45d645b011ac083581f965ce7951771a1f98 (patch) | |
tree | 91002bcf3a9b841258b467fcfe66c212bf634b2f | |
parent | f70e973ddb9b9d6e32d40436b55a20463e78b196 (diff) | |
download | sink-4a6f45d645b011ac083581f965ce7951771a1f98.tar.gz sink-4a6f45d645b011ac083581f965ce7951771a1f98.zip |
Fixed maildirresourcetest
-rw-r--r-- | examples/maildirresource/maildirresource.cpp | 4 | ||||
-rw-r--r-- | tests/maildirresourcetest.cpp | 16 |
2 files changed, 14 insertions, 6 deletions
diff --git a/examples/maildirresource/maildirresource.cpp b/examples/maildirresource/maildirresource.cpp index f888b5d..8770ff0 100644 --- a/examples/maildirresource/maildirresource.cpp +++ b/examples/maildirresource/maildirresource.cpp | |||
@@ -52,6 +52,10 @@ MaildirResource::MaildirResource(const QByteArray &instanceIdentifier, const QSh | |||
52 | QVector<Akonadi2::Preprocessor*>() << new DefaultIndexUpdater<Akonadi2::ApplicationDomain::Folder>); | 52 | QVector<Akonadi2::Preprocessor*>() << new DefaultIndexUpdater<Akonadi2::ApplicationDomain::Folder>); |
53 | auto config = ResourceConfig::getConfiguration(instanceIdentifier); | 53 | auto config = ResourceConfig::getConfiguration(instanceIdentifier); |
54 | mMaildirPath = config.value("path").toString(); | 54 | mMaildirPath = config.value("path").toString(); |
55 | //Chop a trailing slash if necessary | ||
56 | if (mMaildirPath.endsWith(QDir::separator())) { | ||
57 | mMaildirPath.chop(1); | ||
58 | } | ||
55 | Trace() << "Started maildir resource for maildir: " << mMaildirPath; | 59 | Trace() << "Started maildir resource for maildir: " << mMaildirPath; |
56 | } | 60 | } |
57 | 61 | ||
diff --git a/tests/maildirresourcetest.cpp b/tests/maildirresourcetest.cpp index bef94ba..d279a36 100644 --- a/tests/maildirresourcetest.cpp +++ b/tests/maildirresourcetest.cpp | |||
@@ -18,8 +18,10 @@ static bool copyRecursively(const QString &srcFilePath, | |||
18 | if (srcFileInfo.isDir()) { | 18 | if (srcFileInfo.isDir()) { |
19 | QDir targetDir(tgtFilePath); | 19 | QDir targetDir(tgtFilePath); |
20 | targetDir.cdUp(); | 20 | targetDir.cdUp(); |
21 | if (!targetDir.mkdir(QFileInfo(tgtFilePath).fileName())) | 21 | if (!targetDir.mkdir(QFileInfo(srcFilePath).fileName())) { |
22 | qWarning() << "Failed to create directory " << tgtFilePath; | ||
22 | return false; | 23 | return false; |
24 | } | ||
23 | QDir sourceDir(srcFilePath); | 25 | QDir sourceDir(srcFilePath); |
24 | QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System); | 26 | QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System); |
25 | foreach (const QString &fileName, fileNames) { | 27 | foreach (const QString &fileName, fileNames) { |
@@ -31,8 +33,10 @@ static bool copyRecursively(const QString &srcFilePath, | |||
31 | return false; | 33 | return false; |
32 | } | 34 | } |
33 | } else { | 35 | } else { |
34 | if (!QFile::copy(srcFilePath, tgtFilePath)) | 36 | if (!QFile::copy(srcFilePath, tgtFilePath)) { |
37 | qWarning() << "Failed to copy file " << tgtFilePath; | ||
35 | return false; | 38 | return false; |
39 | } | ||
36 | } | 40 | } |
37 | return true; | 41 | return true; |
38 | } | 42 | } |
@@ -45,13 +49,13 @@ static bool copyRecursively(const QString &srcFilePath, | |||
45 | class MaildirResourceTest : public QObject | 49 | class MaildirResourceTest : public QObject |
46 | { | 50 | { |
47 | Q_OBJECT | 51 | Q_OBJECT |
52 | |||
53 | QTemporaryDir tempDir; | ||
48 | private Q_SLOTS: | 54 | private Q_SLOTS: |
49 | void initTestCase() | 55 | void initTestCase() |
50 | { | 56 | { |
51 | auto targetPath = QDir::tempPath() + QDir::separator() + "maildirresourcetest" + QDir::separator() + "maildir1"; | 57 | QVERIFY(tempDir.isValid()); |
52 | QDir dir(targetPath); | 58 | auto targetPath = tempDir.path() + QDir::separator() + "maildir1/"; |
53 | dir.removeRecursively(); | ||
54 | |||
55 | copyRecursively(TESTDATAPATH "/maildir1", targetPath); | 59 | copyRecursively(TESTDATAPATH "/maildir1", targetPath); |
56 | 60 | ||
57 | Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Trace); | 61 | Akonadi2::Log::setDebugOutputLevel(Akonadi2::Log::Trace); |