_ui->encryptionMessage->setIcon({});
initializeE2eEncryption();
checkClientSideEncryptionState();
+
+ const auto account = _accountState->account();
+ if (account->e2e()->_mnemonic.isEmpty()) {
+ FolderMan::instance()->removeE2eFiles(account);
+ }
}
void AccountSettings::removeActionFromEncryptionMessage(const QString &actionId)
msgBox->open();
}
+void Folder::removeLocalE2eFiles()
+{
+ qCDebug(lcFolder) << "Removing local E2EE files";
+ QByteArrayList e2eFiles;
+ const auto couldGetFiles = _journal.getFilesBelowPath("", [&e2eFiles](const SyncJournalFileRecord &rec) {
+ if (rec._isE2eEncrypted) {
+ e2eFiles.append(rec._path);
+ }
+ });
+
+ if (!couldGetFiles) {
+ qCWarning(lcFolder) << "Could not fetch E2EE files to delete in this folder:" << path();
+ return;
+ } else if (e2eFiles.isEmpty()) {
+ qCWarning(lcFolder) << "No E2EE files found at path" << path();
+ return;
+ }
+
+ const auto currentSyncPaused = syncPaused();
+ setSyncPaused(true);
+
+ qCDebug(lcFolder) << "About to remove: " << e2eFiles;
+
+ for (const auto &e2eFilePath : qAsConst(e2eFiles)) {
+ if (!_journal.deleteFileRecord(e2eFilePath, true)) {
+ qCWarning(lcFolder) << "Failed to delete file record from local DB" << e2eFilePath
+ << "it might have already been deleted.";
+ continue;
+ }
+
+ qCDebug(lcFolder) << "Removing local copy of" << e2eFilePath;
+
+ const auto fullPath = QString(path() + e2eFilePath);
+ const QFileInfo pathInfo(fullPath);
+
+ if (pathInfo.isDir() && pathInfo.exists()) {
+ QDir dir(fullPath);
+ if (!dir.removeRecursively()) {
+ qCWarning(lcFolder) << "Unable to remove directory and contents at:" << fullPath;
+ }
+ } else if (pathInfo.exists()) {
+ if (!QFile::remove(fullPath)) {
+ qCWarning(lcFolder) << "Unable to delete file:" << fullPath;
+ }
+ } else {
+ qCWarning(lcFolder) << "Unable to delete:" << fullPath << "as it does not exist!";
+ }
+ }
+
+ setSyncPaused(currentSyncPaused);
+ _journal.forceRemoteDiscoveryNextSync();
+ scheduleThisFolderSoon();
+}
+
QString Folder::fileFromLocalPath(const QString &localPath) const
{
return localPath.mid(cleanPath().length() + 1);
scheduleFolderNext(folder);
}
+void FolderMan::removeE2eFiles(const AccountPtr &account) const
+{
+ Q_ASSERT(account->e2e()->_mnemonic.isEmpty());
+ for (const auto folder : map()) {
+ if(folder->accountState()->account()->id() == account->id()) {
+ folder->removeLocalE2eFiles();
+ }
+ }
+}
+
void FolderMan::slotScheduleAppRestart()
{
_appRestartRequired = true;