Remove unused methods on ClientSideEncryption
authorKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 8 Dec 2020 14:42:28 +0000 (15:42 +0100)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:59:23 +0000 (10:59 +0100)
Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
src/libsync/clientsideencryption.cpp
src/libsync/clientsideencryption.h
src/libsync/encryptfolderjob.cpp

index dcd512d1bd7783f3591e0073eed2d04a69e4ba1e..5585fdb3120cb8fb91a739754c4e65414441ad45 100644 (file)
@@ -830,12 +830,6 @@ void ClientSideEncryption::publicKeyFetched(Job *incoming) {
     job->start();
 }
 
-void ClientSideEncryption::setFolderEncryptedStatus(const QString& folder, bool status)
-{
-    qCDebug(lcCse) << "Setting folder" << folder << "as encrypted" << status;
-    _folder2encryptedStatus[folder] = status;
-}
-
 void ClientSideEncryption::privateKeyFetched(Job *incoming) {
     auto *readJob = static_cast<ReadPasswordJob *>(incoming);
 
@@ -1091,17 +1085,6 @@ void ClientSideEncryption::generateCSR(EVP_PKEY *keyPair)
     job->start();
 }
 
-void ClientSideEncryption::setTokenForFolder(const QByteArray& folderId, const QByteArray& token)
-{
-    _folder2token[folderId] = token;
-}
-
-QByteArray ClientSideEncryption::tokenForFolder(const QByteArray& folderId) const
-{
-    Q_ASSERT(_folder2token.contains(folderId));
-    return _folder2token[folderId];
-}
-
 void ClientSideEncryption::encryptPrivateKey()
 {
     QStringList list = WordList::getRandomWords(12);
@@ -1548,29 +1531,6 @@ QVector<EncryptedFile> FolderMetadata::files() const {
     return _files;
 }
 
-bool ClientSideEncryption::isFolderEncrypted(const QString& path) const {
-  auto it = _folder2encryptedStatus.constFind(path);
-  if (it == _folder2encryptedStatus.constEnd())
-    return false;
-  return (*it);
-}
-
-bool ClientSideEncryption::isAnyParentFolderEncrypted(const QString &path) const
-{
-    int slashPosition = 0;
-
-    while ((slashPosition = path.indexOf("/", slashPosition + 1)) != -1) {
-        // Ignore the last slash
-        if (slashPosition == path.length() - 1) break;
-
-        if (isFolderEncrypted(path.left(slashPosition + 1))) {
-            return true;
-        }
-    }
-
-    return false;
-}
-
 bool EncryptionHelper::fileEncryption(const QByteArray &key, const QByteArray &iv, QFile *input, QFile *output, QByteArray& returnTag)
 {
     if (!input->open(QIODevice::ReadOnly)) {
index 355e965358d84be2086611108778bf5105ddba47..5622c2d0bef923c76f469ace3b466e2bc55adea3 100644 (file)
@@ -80,15 +80,8 @@ public:
     void generateKeyPair();
     void generateCSR(EVP_PKEY *keyPair);
     void encryptPrivateKey();
-    void setTokenForFolder(const QByteArray& folder, const QByteArray& token);
-    QByteArray tokenForFolder(const QByteArray& folder) const;
     void fetchFolderEncryptedStatus();
 
-    // to be used together with FolderStatusModel::FolderInfo::_path.
-    bool isFolderEncrypted(const QString& path) const;
-    bool isAnyParentFolderEncrypted(const QString &path) const;
-    void setFolderEncryptedStatus(const QString& path, bool status);
-
     void forgetSensitiveData();
 
     bool newMnemonicGenerated() const;
@@ -126,7 +119,6 @@ private:
     bool isInitialized = false;
     bool _refreshingEncryptionStatus = false;
     //TODO: Save this on disk.
-    QHash<QByteArray, QByteArray> _folder2token;
     QHash<QString, bool> _folder2encryptedStatus;
     QVector<GetFolderEncryptStatusJob*> _folderStatusJobs;
 
index 68b446c1d2a7f97bb402dc09a2a3dd9d3dcc85a6..798778ea9add7aa92db36e2bd07e06915121e038 100644 (file)
@@ -47,8 +47,6 @@ QString EncryptFolderJob::errorString() const
 
 void EncryptFolderJob::slotEncryptionFlagSuccess(const QByteArray &fileId)
 {
-    _account->e2e()->setFolderEncryptedStatus(_path + '/', true);
-
     SyncJournalFileRecord rec;
     _journal->getFileRecord(_path, &rec);
     if (rec.isValid()) {