summaryrefslogtreecommitdiffstats
path: root/common/mailpreprocessor.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-11 11:55:29 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-11 11:55:29 +0200
commit3a3118e768e1447dc7524328e84b8d7faef81fe1 (patch)
treeaf5582170ed6164fffc9365f34b17bf449c0db40 /common/mailpreprocessor.cpp
parentf9379318d801df204cc50385c5eca1f28e91755e (diff)
parentce2fd2666f084eebe443598f6f3740a02913091e (diff)
downloadsink-3a3118e768e1447dc7524328e84b8d7faef81fe1.tar.gz
sink-3a3118e768e1447dc7524328e84b8d7faef81fe1.zip
Merge branch 'feature/notifications' into develop
Diffstat (limited to 'common/mailpreprocessor.cpp')
-rw-r--r--common/mailpreprocessor.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/common/mailpreprocessor.cpp b/common/mailpreprocessor.cpp
index 005a93e..2863ad4 100644
--- a/common/mailpreprocessor.cpp
+++ b/common/mailpreprocessor.cpp
@@ -29,6 +29,8 @@
29 29
30using namespace Sink; 30using namespace Sink;
31 31
32SINK_DEBUG_AREA("mailpreprocessor")
33
32QString MailPropertyExtractor::getFilePathFromMimeMessagePath(const QString &s) const 34QString MailPropertyExtractor::getFilePathFromMimeMessagePath(const QString &s) const
33{ 35{
34 return s; 36 return s;
@@ -37,20 +39,24 @@ QString MailPropertyExtractor::getFilePathFromMimeMessagePath(const QString &s)
37void MailPropertyExtractor::updatedIndexedProperties(Sink::ApplicationDomain::Mail &mail) 39void MailPropertyExtractor::updatedIndexedProperties(Sink::ApplicationDomain::Mail &mail)
38{ 40{
39 const auto mimeMessagePath = getFilePathFromMimeMessagePath(mail.getMimeMessagePath()); 41 const auto mimeMessagePath = getFilePathFromMimeMessagePath(mail.getMimeMessagePath());
40 Trace() << "Updating indexed properties " << mimeMessagePath; 42 if (mimeMessagePath.isNull()) {
43 SinkTrace() << "No mime message";
44 return;
45 }
46 SinkTrace() << "Updating indexed properties " << mimeMessagePath;
41 QFile f(mimeMessagePath); 47 QFile f(mimeMessagePath);
42 if (!f.open(QIODevice::ReadOnly)) { 48 if (!f.open(QIODevice::ReadOnly)) {
43 Warning() << "Failed to open the file: " << mimeMessagePath; 49 SinkWarning() << "Failed to open the file: " << mimeMessagePath;
44 return; 50 return;
45 } 51 }
46 if (!f.size()) { 52 if (!f.size()) {
47 Warning() << "The file is empty."; 53 SinkWarning() << "The file is empty.";
48 return; 54 return;
49 } 55 }
50 const auto mappedSize = qMin((qint64)8000, f.size()); 56 const auto mappedSize = qMin((qint64)8000, f.size());
51 auto mapped = f.map(0, mappedSize); 57 auto mapped = f.map(0, mappedSize);
52 if (!mapped) { 58 if (!mapped) {
53 Warning() << "Failed to map the file: " << f.errorString(); 59 SinkWarning() << "Failed to map the file: " << f.errorString();
54 return; 60 return;
55 } 61 }
56 62
@@ -85,15 +91,15 @@ QString MimeMessageMover::moveMessage(const QString &oldPath, const Sink::Applic
85 const auto filePath = directory + "/" + mail.identifier(); 91 const auto filePath = directory + "/" + mail.identifier();
86 if (oldPath != filePath) { 92 if (oldPath != filePath) {
87 if (!QDir().mkpath(directory)) { 93 if (!QDir().mkpath(directory)) {
88 Warning() << "Failed to create the directory: " << directory; 94 SinkWarning() << "Failed to create the directory: " << directory;
89 } 95 }
90 QFile::remove(filePath); 96 QFile::remove(filePath);
91 QFile origFile(oldPath); 97 QFile origFile(oldPath);
92 if (!origFile.open(QIODevice::ReadWrite)) { 98 if (!origFile.open(QIODevice::ReadWrite)) {
93 Warning() << "Failed to open the original file with write rights: " << origFile.errorString(); 99 SinkWarning() << "Failed to open the original file with write rights: " << origFile.errorString();
94 } 100 }
95 if (!origFile.rename(filePath)) { 101 if (!origFile.rename(filePath)) {
96 Warning() << "Failed to move the file from: " << oldPath << " to " << filePath << ". " << origFile.errorString(); 102 SinkWarning() << "Failed to move the file from: " << oldPath << " to " << filePath << ". " << origFile.errorString();
97 } 103 }
98 origFile.close(); 104 origFile.close();
99 return filePath; 105 return filePath;