Skip to content

Commit

Permalink
Refactoring and review comments fixing. III.
Browse files Browse the repository at this point in the history
Signed-off-by: alex-z <[email protected]>
  • Loading branch information
allexzander committed Jan 19, 2024
1 parent c929570 commit 734c1d8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
4 changes: 0 additions & 4 deletions src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1980,10 +1980,6 @@ DiscoverySingleDirectoryJob *ProcessDirectoryJob::startAsyncServerQuery()
connect(serverJob, &DiscoverySingleDirectoryJob::finished, this, [this, serverJob](const auto &results) {
if (_dirItem) {
if (_dirItem->isEncrypted()) {
if (_dirItem->_encryptedFileName.isEmpty()) {
_discoveryData->_topLevelE2eeFoldersMetadata[_dirItem->_file + QLatin1Char('/')] = serverJob->e2eeFolderMetadata();
}

_dirItem->_isFileDropDetected = serverJob->isFileDropDetected();

SyncJournalFileRecord record;
Expand Down
22 changes: 9 additions & 13 deletions src/libsync/discoveryphase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,6 @@ bool DiscoverySingleDirectoryJob::isFileDropDetected() const
return _isFileDropDetected;
}

QSharedPointer<FolderMetadata> DiscoverySingleDirectoryJob::e2eeFolderMetadata() const
{
return _e2EeFolderMetadata;
}

bool DiscoverySingleDirectoryJob::encryptedMetadataNeedUpdate() const
{
return _encryptedMetadataNeedUpdate;
Expand Down Expand Up @@ -691,22 +686,23 @@ void DiscoverySingleDirectoryJob::metadataReceived(const QJsonDocument &json, in
}
}

_e2EeFolderMetadata.reset(new FolderMetadata(_account,
const auto e2EeFolderMetadata = new FolderMetadata(_account,
statusCode == 404 ? QByteArray{} : json.toJson(QJsonDocument::Compact),
RootEncryptedFolderInfo(topLevelFolderPath),
job->signature()));
connect(_e2EeFolderMetadata.data(), &FolderMetadata::setupComplete, this, [this] {
if (!_e2EeFolderMetadata->isValid()) {
job->signature());
connect(e2EeFolderMetadata, &FolderMetadata::setupComplete, this, [this, e2EeFolderMetadata] {
e2EeFolderMetadata->deleteLater();
if (!e2EeFolderMetadata->isValid()) {
emit finished(HttpError{0, tr("Encrypted metadata setup error!")});
deleteLater();
return;
}
_isFileDropDetected = _e2EeFolderMetadata->isFileDropPresent();
_encryptedMetadataNeedUpdate = _e2EeFolderMetadata->encryptedMetadataNeedUpdate();
_isFileDropDetected = e2EeFolderMetadata->isFileDropPresent();
_encryptedMetadataNeedUpdate = e2EeFolderMetadata->encryptedMetadataNeedUpdate();
_encryptionStatusRequired = EncryptionStatusEnums::fromEndToEndEncryptionApiVersion(_account->capabilities().clientSideEncryptionVersion());
_encryptionStatusCurrent = _e2EeFolderMetadata->existingMetadataEncryptionStatus();
_encryptionStatusCurrent = e2EeFolderMetadata->existingMetadataEncryptionStatus();

const auto encryptedFiles = _e2EeFolderMetadata->files();
const auto encryptedFiles = e2EeFolderMetadata->files();

const auto findEncryptedFile = [=](const QString &name) {
const auto it = std::find_if(std::cbegin(encryptedFiles), std::cend(encryptedFiles), [=](const FolderMetadata::EncryptedFile &file) {
Expand Down
4 changes: 0 additions & 4 deletions src/libsync/discoveryphase.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ class DiscoverySingleDirectoryJob : public QObject
void start();
void abort();
[[nodiscard]] bool isFileDropDetected() const;
[[nodiscard]] QSharedPointer<FolderMetadata> e2eeFolderMetadata() const;
[[nodiscard]] bool encryptedMetadataNeedUpdate() const;
[[nodiscard]] SyncFileItem::EncryptionStatus currentEncryptionStatus() const;
[[nodiscard]] SyncFileItem::EncryptionStatus requiredEncryptionStatus() const;
Expand Down Expand Up @@ -197,8 +196,6 @@ private slots:
int64_t _size = 0;
QString _error;
QPointer<LsColJob> _lsColJob;

QSharedPointer<FolderMetadata> _e2EeFolderMetadata;

// store top level E2EE folder paths as they are used later when discovering nested folders
QSet<QString> _topLevelE2eeFolderPaths;
Expand Down Expand Up @@ -337,7 +334,6 @@ class DiscoveryPhase : public QObject
bool _noCaseConflictRecordsInDb = false;

QSet<QString> _topLevelE2eeFolderPaths;
QMap<QString, QSharedPointer<FolderMetadata>> _topLevelE2eeFoldersMetadata;

signals:
void fatalError(const QString &errorString, const OCC::ErrorCategory errorCategory);
Expand Down

0 comments on commit 734c1d8

Please sign in to comment.