summaryrefslogtreecommitdiffstats
path: root/common/mailpreprocessor.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-12-09 16:31:30 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-12-09 16:31:30 +0100
commit9f6751df8e6f483b112c2b24c0bc725924f17356 (patch)
treedf312279bacc53e5bb6b6181fc25282ce5b0dd8e /common/mailpreprocessor.cpp
parent9c8e4612403fc2accc26ac2b49670394972f1293 (diff)
downloadsink-9f6751df8e6f483b112c2b24c0bc725924f17356.tar.gz
sink-9f6751df8e6f483b112c2b24c0bc725924f17356.zip
Move the BLOB property handling to the entitystore.
This is really part of the storage, and will help us to cleanly implement features like moving properties into a temporary place when reading in a clean way as well.
Diffstat (limited to 'common/mailpreprocessor.cpp')
-rw-r--r--common/mailpreprocessor.cpp46
1 files changed, 0 insertions, 46 deletions
diff --git a/common/mailpreprocessor.cpp b/common/mailpreprocessor.cpp
index 575ff4b..bde8a64 100644
--- a/common/mailpreprocessor.cpp
+++ b/common/mailpreprocessor.cpp
@@ -152,49 +152,3 @@ void MailPropertyExtractor::modifiedEntity(const Sink::ApplicationDomain::Mail &
152 } 152 }
153} 153}
154 154
155
156MimeMessageMover::MimeMessageMover() : Sink::EntityPreprocessor<ApplicationDomain::Mail>()
157{
158}
159
160QString MimeMessageMover::moveMessage(const QString &oldPath, const Sink::ApplicationDomain::Mail &mail)
161{
162 const auto directory = Sink::resourceStorageLocation(resourceInstanceIdentifier());
163 const auto filePath = directory + "/" + mail.identifier();
164 if (oldPath != filePath) {
165 if (!QDir().mkpath(directory)) {
166 SinkWarning() << "Failed to create the directory: " << directory;
167 }
168 QFile::remove(filePath);
169 QFile origFile(oldPath);
170 if (!origFile.open(QIODevice::ReadWrite)) {
171 SinkWarning() << "Failed to open the original file with write rights: " << origFile.errorString();
172 }
173 if (!origFile.rename(filePath)) {
174 SinkWarning() << "Failed to move the file from: " << oldPath << " to " << filePath << ". " << origFile.errorString();
175 }
176 origFile.close();
177 return filePath;
178 }
179 return oldPath;
180}
181
182void MimeMessageMover::newEntity(Sink::ApplicationDomain::Mail &mail)
183{
184 if (!mail.getMimeMessagePath().isEmpty()) {
185 mail.setMimeMessagePath(moveMessage(mail.getMimeMessagePath(), mail));
186 }
187}
188
189void MimeMessageMover::modifiedEntity(const Sink::ApplicationDomain::Mail &oldMail, Sink::ApplicationDomain::Mail &newMail)
190{
191 if (!newMail.getMimeMessagePath().isEmpty()) {
192 newMail.setMimeMessagePath(moveMessage(newMail.getMimeMessagePath(), newMail));
193 }
194}
195
196void MimeMessageMover::deletedEntity(const Sink::ApplicationDomain::Mail &mail)
197{
198 QFile::remove(mail.getMimeMessagePath());
199}
200