From 9f6751df8e6f483b112c2b24c0bc725924f17356 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 9 Dec 2016 16:31:30 +0100 Subject: 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. --- common/mailpreprocessor.cpp | 46 --------------------------------------------- 1 file changed, 46 deletions(-) (limited to 'common/mailpreprocessor.cpp') 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 & } } - -MimeMessageMover::MimeMessageMover() : Sink::EntityPreprocessor() -{ -} - -QString MimeMessageMover::moveMessage(const QString &oldPath, const Sink::ApplicationDomain::Mail &mail) -{ - const auto directory = Sink::resourceStorageLocation(resourceInstanceIdentifier()); - const auto filePath = directory + "/" + mail.identifier(); - if (oldPath != filePath) { - if (!QDir().mkpath(directory)) { - SinkWarning() << "Failed to create the directory: " << directory; - } - QFile::remove(filePath); - QFile origFile(oldPath); - if (!origFile.open(QIODevice::ReadWrite)) { - SinkWarning() << "Failed to open the original file with write rights: " << origFile.errorString(); - } - if (!origFile.rename(filePath)) { - SinkWarning() << "Failed to move the file from: " << oldPath << " to " << filePath << ". " << origFile.errorString(); - } - origFile.close(); - return filePath; - } - return oldPath; -} - -void MimeMessageMover::newEntity(Sink::ApplicationDomain::Mail &mail) -{ - if (!mail.getMimeMessagePath().isEmpty()) { - mail.setMimeMessagePath(moveMessage(mail.getMimeMessagePath(), mail)); - } -} - -void MimeMessageMover::modifiedEntity(const Sink::ApplicationDomain::Mail &oldMail, Sink::ApplicationDomain::Mail &newMail) -{ - if (!newMail.getMimeMessagePath().isEmpty()) { - newMail.setMimeMessagePath(moveMessage(newMail.getMimeMessagePath(), newMail)); - } -} - -void MimeMessageMover::deletedEntity(const Sink::ApplicationDomain::Mail &mail) -{ - QFile::remove(mail.getMimeMessagePath()); -} - -- cgit v1.2.3