mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 13:05:51 +03:00
when migrating older metadata, do not check missing checksum
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
parent
d1c18ecf2a
commit
f181b91875
1 changed files with 22 additions and 10 deletions
|
@ -1541,8 +1541,10 @@ void FolderMetadata::setupExistingMetadata(const QByteArray& metadata)
|
|||
}
|
||||
}
|
||||
|
||||
auto migratedMetadata = false;
|
||||
if (_metadataKey.isEmpty()) {
|
||||
qCDebug(lcCse()) << "Migrating from v1.1 to v1.2";
|
||||
migratedMetadata = true;
|
||||
|
||||
if (metadataKeys.isEmpty()) {
|
||||
qCDebug(lcCse()) << "Could not migrate. No metadata keys found!";
|
||||
|
@ -1556,14 +1558,16 @@ void FolderMetadata::setupExistingMetadata(const QByteArray& metadata)
|
|||
}
|
||||
}
|
||||
|
||||
if (_metadataKey.isEmpty()) {
|
||||
qCDebug(lcCse()) << "Could not setup existing metadata with missing metadataKeys!";
|
||||
return;
|
||||
}
|
||||
|
||||
const auto sharing = metadataObj["sharing"].toString().toLocal8Bit();
|
||||
const auto files = metaDataDoc.object()["files"].toObject();
|
||||
const auto metadataKey = metaDataDoc.object()["metadata"].toObject()["metadataKey"].toString().toUtf8();
|
||||
const auto metadataKeyChecksum = metaDataDoc.object()["metadata"].toObject()["checksum"].toString().toUtf8();
|
||||
|
||||
QByteArray sharing = metadataObj["sharing"].toString().toLocal8Bit();
|
||||
QJsonObject files = metaDataDoc.object()["files"].toObject();
|
||||
|
||||
_fileDrop = metaDataDoc.object().value("filedrop").toObject();
|
||||
|
||||
// Iterate over the document to store the keys. I'm unsure that the keys are in order,
|
||||
|
@ -1610,15 +1614,23 @@ void FolderMetadata::setupExistingMetadata(const QByteArray& metadata)
|
|||
file.encryptionKey = QByteArray::fromBase64(decryptedFileObj["key"].toString().toLocal8Bit());
|
||||
file.mimetype = decryptedFileObj["mimetype"].toString().toLocal8Bit();
|
||||
|
||||
if (!checkMetadataKeyChecksum(metadataKey, metadataKeyChecksum)) {
|
||||
_metadataKey.clear();
|
||||
_files.clear();
|
||||
return;
|
||||
// In case we wrongly stored "inode/directory" we try to recover from it
|
||||
if (file.mimetype == QByteArrayLiteral("inode/directory")) {
|
||||
file.mimetype = QByteArrayLiteral("httpd/unix-directory");
|
||||
}
|
||||
|
||||
// decryption finished, create new metadata key to be used for encryption
|
||||
_metadataKey = EncryptionHelper::generateRandom(metadataKeySize);
|
||||
_isMetadataSetup = true;
|
||||
_files.push_back(file);
|
||||
}
|
||||
|
||||
if (!migratedMetadata && !checkMetadataKeyChecksum(metadataKey, metadataKeyChecksum)) {
|
||||
_metadataKey.clear();
|
||||
_files.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
// decryption finished, create new metadata key to be used for encryption
|
||||
_metadataKey = EncryptionHelper::generateRandom(metadataKeySize);
|
||||
_isMetadataSetup = true;
|
||||
}
|
||||
|
||||
// RSA/ECB/OAEPWithSHA-256AndMGF1Padding using private / public key.
|
||||
|
|
Loading…
Reference in a new issue