mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
46 lines
1.6 KiB
C++
46 lines
1.6 KiB
C++
/*
|
|
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
#include "rootencryptedfolderinfo.h"
|
|
|
|
namespace OCC
|
|
{
|
|
RootEncryptedFolderInfo::RootEncryptedFolderInfo()
|
|
{
|
|
*this = RootEncryptedFolderInfo::makeDefault();
|
|
}
|
|
|
|
RootEncryptedFolderInfo::RootEncryptedFolderInfo(const QString &remotePath,
|
|
const QByteArray &encryptionKey,
|
|
const QByteArray &decryptionKey,
|
|
const QSet<QByteArray> &checksums,
|
|
const quint64 counter)
|
|
: path(remotePath)
|
|
, keyForEncryption(encryptionKey)
|
|
, keyForDecryption(decryptionKey)
|
|
, keyChecksums(checksums)
|
|
, counter(counter)
|
|
{
|
|
}
|
|
|
|
RootEncryptedFolderInfo RootEncryptedFolderInfo::makeDefault()
|
|
{
|
|
return RootEncryptedFolderInfo{QStringLiteral("/")};
|
|
}
|
|
|
|
QString RootEncryptedFolderInfo::createRootPath(const QString ¤tPath, const QString &topLevelPath)
|
|
{
|
|
const auto currentPathNoLeadingSlash = currentPath.startsWith(QLatin1Char('/')) ? currentPath.mid(1) : currentPath;
|
|
const auto topLevelPathNoLeadingSlash = topLevelPath.startsWith(QLatin1Char('/')) ? topLevelPath.mid(1) : topLevelPath;
|
|
|
|
return currentPathNoLeadingSlash == topLevelPathNoLeadingSlash ? QStringLiteral("/") : topLevelPath;
|
|
}
|
|
|
|
bool RootEncryptedFolderInfo::keysSet() const
|
|
{
|
|
return !keyForEncryption.isEmpty() && !keyForDecryption.isEmpty() && !keyChecksums.isEmpty();
|
|
}
|
|
}
|