Skip to content

Commit

Permalink
Renaming.
Browse files Browse the repository at this point in the history
Signed-off-by: alex-z <[email protected]>
  • Loading branch information
allexzander committed Jul 14, 2023
1 parent c6f5256 commit 06e6aa1
Show file tree
Hide file tree
Showing 16 changed files with 92 additions and 92 deletions.
34 changes: 17 additions & 17 deletions src/libsync/basepropagateremotedeleteencrypted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,25 @@ void BasePropagateRemoteDeleteEncrypted::fetchMetadataForPath(const QString &pat
return;
}

_fetchAndUploadE2eeFolderMetadataJob.reset(new EncryptedFolderMetadataHandler(_propagator->account(),
_encryptedFolderMetadataHandler.reset(new EncryptedFolderMetadataHandler(_propagator->account(),
_fullFolderRemotePath,
_propagator->_journal,
rec.path()));

connect(_fetchAndUploadE2eeFolderMetadataJob.data(),
connect(_encryptedFolderMetadataHandler.data(),
&EncryptedFolderMetadataHandler::fetchFinished,
this,
&BasePropagateRemoteDeleteEncrypted::slotFetchMetadataJobFinished);
connect(_fetchAndUploadE2eeFolderMetadataJob.data(),
connect(_encryptedFolderMetadataHandler.data(),
&EncryptedFolderMetadataHandler::uploadFinished,
this,
&BasePropagateRemoteDeleteEncrypted::slotUpdateMetadataJobFinished);
_fetchAndUploadE2eeFolderMetadataJob->fetchMetadata();
_encryptedFolderMetadataHandler->fetchMetadata();
}

void BasePropagateRemoteDeleteEncrypted::uploadMetadata(bool keepLock)
{
_fetchAndUploadE2eeFolderMetadataJob->uploadMetadata(keepLock);
_encryptedFolderMetadataHandler->uploadMetadata(keepLock);
}

void BasePropagateRemoteDeleteEncrypted::slotFolderUnLockFinished(const QByteArray &folderId, int statusCode)
Expand Down Expand Up @@ -154,9 +154,9 @@ void BasePropagateRemoteDeleteEncrypted::deleteRemoteItem(const QString &filenam
qCInfo(ABSTRACT_PROPAGATE_REMOVE_ENCRYPTED) << "Deleting nested encrypted item" << filename;

const auto deleteJob = new DeleteJob(_propagator->account(), _propagator->fullRemotePath(filename), this);
if (_fetchAndUploadE2eeFolderMetadataJob && _fetchAndUploadE2eeFolderMetadataJob->folderMetadata()
&& _fetchAndUploadE2eeFolderMetadataJob->folderMetadata()->isValid()) {
deleteJob->setFolderToken(_fetchAndUploadE2eeFolderMetadataJob->folderToken());
if (_encryptedFolderMetadataHandler && _encryptedFolderMetadataHandler->folderMetadata()
&& _encryptedFolderMetadataHandler->folderMetadata()->isValid()) {
deleteJob->setFolderToken(_encryptedFolderMetadataHandler->folderToken());
}

connect(deleteJob, &DeleteJob::finishedSignal, this, &BasePropagateRemoteDeleteEncrypted::slotDeleteRemoteItemFinished);
Expand All @@ -165,22 +165,22 @@ void BasePropagateRemoteDeleteEncrypted::deleteRemoteItem(const QString &filenam

void BasePropagateRemoteDeleteEncrypted::unlockFolder(bool success)
{
if (!_fetchAndUploadE2eeFolderMetadataJob->isFolderLocked()) {
if (!_encryptedFolderMetadataHandler->isFolderLocked()) {
emit finished(true);
return;
}

qCDebug(ABSTRACT_PROPAGATE_REMOVE_ENCRYPTED) << "Unlocking folder" << _fetchAndUploadE2eeFolderMetadataJob->folderId();
qCDebug(ABSTRACT_PROPAGATE_REMOVE_ENCRYPTED) << "Unlocking folder" << _encryptedFolderMetadataHandler->folderId();

connect(_fetchAndUploadE2eeFolderMetadataJob.data(), &EncryptedFolderMetadataHandler::folderUnlocked, this, &BasePropagateRemoteDeleteEncrypted::slotFolderUnLockFinished);
_fetchAndUploadE2eeFolderMetadataJob->unlockFolder(success);
connect(_encryptedFolderMetadataHandler.data(), &EncryptedFolderMetadataHandler::folderUnlocked, this, &BasePropagateRemoteDeleteEncrypted::slotFolderUnLockFinished);
_encryptedFolderMetadataHandler->unlockFolder(success);
}

void BasePropagateRemoteDeleteEncrypted::taskFailed()
{
qCDebug(ABSTRACT_PROPAGATE_REMOVE_ENCRYPTED) << "Task failed for job" << sender();
_isTaskFailed = true;
if (_fetchAndUploadE2eeFolderMetadataJob->isFolderLocked()) {
if (_encryptedFolderMetadataHandler->isFolderLocked()) {
unlockFolder(false);
} else {
emit finished(false);
Expand All @@ -189,16 +189,16 @@ void BasePropagateRemoteDeleteEncrypted::taskFailed()

QSharedPointer<FolderMetadata> BasePropagateRemoteDeleteEncrypted::folderMetadata() const
{
Q_ASSERT(_fetchAndUploadE2eeFolderMetadataJob->folderMetadata());
if (!_fetchAndUploadE2eeFolderMetadataJob->folderMetadata()) {
Q_ASSERT(_encryptedFolderMetadataHandler->folderMetadata());
if (!_encryptedFolderMetadataHandler->folderMetadata()) {
qCWarning(ABSTRACT_PROPAGATE_REMOVE_ENCRYPTED) << "Metadata is null!";
}
return _fetchAndUploadE2eeFolderMetadataJob->folderMetadata();
return _encryptedFolderMetadataHandler->folderMetadata();
}

const QByteArray BasePropagateRemoteDeleteEncrypted::folderToken() const
{
return _fetchAndUploadE2eeFolderMetadataJob->folderToken();
return _encryptedFolderMetadataHandler->folderToken();
}

} // namespace OCC
2 changes: 1 addition & 1 deletion src/libsync/basepropagateremotedeleteencrypted.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected slots:
QString _fullFolderRemotePath;

private:
QScopedPointer<EncryptedFolderMetadataHandler> _fetchAndUploadE2eeFolderMetadataJob;
QScopedPointer<EncryptedFolderMetadataHandler> _encryptedFolderMetadataHandler;
};

}
14 changes: 7 additions & 7 deletions src/libsync/encryptfolderjob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ EncryptFolderJob::EncryptFolderJob(const AccountPtr &account, SyncJournalDb *jou
SyncJournalFileRecord rec;
const auto currentPath = !_pathNonEncrypted.isEmpty() ? _pathNonEncrypted : _path;
[[maybe_unused]] const auto result = _journal->getRootE2eFolderRecord(currentPath, &rec);
_fetchAndUploadE2eeFolderMetadataJob.reset(new EncryptedFolderMetadataHandler(account, _path, _journal, rec.path()));
_encryptedFolderMetadataHandler.reset(new EncryptedFolderMetadataHandler(account, _path, _journal, rec.path()));
}

void EncryptFolderJob::slotSetEncryptionFlag()
Expand Down Expand Up @@ -127,27 +127,27 @@ void EncryptFolderJob::uploadMetadata()
emit finished(Error, EncryptionStatusEnums::ItemEncryptionStatus::NotEncrypted);
return;
}
_fetchAndUploadE2eeFolderMetadataJob->setMetadata(emptyMetadata);
_fetchAndUploadE2eeFolderMetadataJob->setFolderId(_fileId);
connect(_fetchAndUploadE2eeFolderMetadataJob.data(),
_encryptedFolderMetadataHandler->setMetadata(emptyMetadata);
_encryptedFolderMetadataHandler->setFolderId(_fileId);
connect(_encryptedFolderMetadataHandler.data(),
&EncryptedFolderMetadataHandler::uploadFinished,
this,
&EncryptFolderJob::slotUploadMetadataFinished);
_fetchAndUploadE2eeFolderMetadataJob->uploadMetadata();
_encryptedFolderMetadataHandler->uploadMetadata();
});
}

void EncryptFolderJob::slotUploadMetadataFinished(int statusCode, const QString &message)
{
if (statusCode != 200) {
qCDebug(lcEncryptFolderJob) << "Update metadata error for folder" << _fetchAndUploadE2eeFolderMetadataJob->folderId() << "with error"
qCDebug(lcEncryptFolderJob) << "Update metadata error for folder" << _encryptedFolderMetadataHandler->folderId() << "with error"
<< message;
qCDebug(lcEncryptFolderJob()) << "Unlocking the folder.";
_errorString = message;
emit finished(Error, EncryptionStatusEnums::ItemEncryptionStatus::NotEncrypted);
return;
}
emit finished(Success, _fetchAndUploadE2eeFolderMetadataJob->folderMetadata()->encryptedMetadataEncryptionStatus());
emit finished(Success, _encryptedFolderMetadataHandler->folderMetadata()->encryptedMetadataEncryptionStatus());
}

}
2 changes: 1 addition & 1 deletion src/libsync/encryptfolderjob.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ private slots:
QString _errorString;
OwncloudPropagator *_propagator = nullptr;
SyncFileItemPtr _item;
QScopedPointer<EncryptedFolderMetadataHandler> _fetchAndUploadE2eeFolderMetadataJob;
QScopedPointer<EncryptedFolderMetadataHandler> _encryptedFolderMetadataHandler;
};
}
8 changes: 4 additions & 4 deletions src/libsync/foldermetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -900,18 +900,18 @@ const QByteArray &FolderMetadata::fileDrop() const

void FolderMetadata::startFetchRootE2eeFolderMetadata(const QString &path)
{
_fetchAndUploadE2eeFolderMetadataJob.reset(new EncryptedFolderMetadataHandler(_account, path, nullptr, "/"));
_encryptedFolderMetadataHandler.reset(new EncryptedFolderMetadataHandler(_account, path, nullptr, "/"));

connect(_fetchAndUploadE2eeFolderMetadataJob.data(),
connect(_encryptedFolderMetadataHandler.data(),
&EncryptedFolderMetadataHandler::fetchFinished,
this,
&FolderMetadata::slotRootE2eeFolderMetadataReceived);
_fetchAndUploadE2eeFolderMetadataJob->fetchMetadata(RootEncryptedFolderInfo::makeDefault() , true);
_encryptedFolderMetadataHandler->fetchMetadata(RootEncryptedFolderInfo::makeDefault() , true);
}

void FolderMetadata::slotRootE2eeFolderMetadataReceived(int statusCode, const QString &message)
{
const auto rootE2eeFolderMetadata = _fetchAndUploadE2eeFolderMetadataJob->folderMetadata();
const auto rootE2eeFolderMetadata = _encryptedFolderMetadataHandler->folderMetadata();
if (!rootE2eeFolderMetadata->isValid() || !rootE2eeFolderMetadata->isVersion2AndUp()) {
initMetadata();
return;
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/foldermetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private slots:

bool _isMetadataValid = false;

QScopedPointer<EncryptedFolderMetadataHandler> _fetchAndUploadE2eeFolderMetadataJob;
QScopedPointer<EncryptedFolderMetadataHandler> _encryptedFolderMetadataHandler;
};

} // namespace OCC
8 changes: 4 additions & 4 deletions src/libsync/propagatedownloadencrypted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ void PropagateDownloadEncrypted::start()
emit failed();
return;
}
_fetchAndUploadE2eeFolderMetadataJob.reset(
_encryptedFolderMetadataHandler.reset(
new EncryptedFolderMetadataHandler(_propagator->account(), _remoteParentPath, _propagator->_journal, rec.path()));

connect(_fetchAndUploadE2eeFolderMetadataJob.data(),
connect(_encryptedFolderMetadataHandler.data(),
&EncryptedFolderMetadataHandler::fetchFinished,
this,
&PropagateDownloadEncrypted::slotFetchMetadataJobFinished);
_fetchAndUploadE2eeFolderMetadataJob->fetchMetadata(true);
_encryptedFolderMetadataHandler->fetchMetadata(true);
}

void PropagateDownloadEncrypted::slotFetchMetadataJobFinished(int statusCode, const QString &message)
Expand All @@ -61,7 +61,7 @@ void PropagateDownloadEncrypted::slotFetchMetadataJobFinished(int statusCode, co

qCDebug(lcPropagateDownloadEncrypted) << "Metadata Received reading" << _item->_instruction << _item->_file << _item->_encryptedFileName;

const auto metadata = _fetchAndUploadE2eeFolderMetadataJob->folderMetadata();
const auto metadata = _encryptedFolderMetadataHandler->folderMetadata();

if (!metadata || !metadata->isValid()) {
emit failed();
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/propagatedownloadencrypted.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private slots:
QString _remoteParentPath;
QString _parentPathInDb;
// TODO: Create a base class with this member in 'protected' and virtual slots for fetch/upload, then refactor this and other similar classes to inherit the base class
QScopedPointer<EncryptedFolderMetadataHandler> _fetchAndUploadE2eeFolderMetadataJob;
QScopedPointer<EncryptedFolderMetadataHandler> _encryptedFolderMetadataHandler;
};

}
Expand Down
24 changes: 12 additions & 12 deletions src/libsync/propagateuploadencrypted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,35 +59,35 @@ void PropagateUploadEncrypted::start()
emit error();
return;
}
_fetchAndUploadE2eeFolderMetadataJob.reset(new EncryptedFolderMetadataHandler(_propagator->account(),
_encryptedFolderMetadataHandler.reset(new EncryptedFolderMetadataHandler(_propagator->account(),
_remoteParentAbsolutePath,
_propagator->_journal,
rec.path()));

connect(_fetchAndUploadE2eeFolderMetadataJob.data(), &EncryptedFolderMetadataHandler::fetchFinished,
connect(_encryptedFolderMetadataHandler.data(), &EncryptedFolderMetadataHandler::fetchFinished,
this, &PropagateUploadEncrypted::slotFetchMetadataJobFinished);
_fetchAndUploadE2eeFolderMetadataJob->fetchMetadata(true);
_encryptedFolderMetadataHandler->fetchMetadata(true);
}

void PropagateUploadEncrypted::unlockFolder()
{
connect(_fetchAndUploadE2eeFolderMetadataJob.data(), &EncryptedFolderMetadataHandler::folderUnlocked, this, &PropagateUploadEncrypted::folderUnlocked);
_fetchAndUploadE2eeFolderMetadataJob->unlockFolder();
connect(_encryptedFolderMetadataHandler.data(), &EncryptedFolderMetadataHandler::folderUnlocked, this, &PropagateUploadEncrypted::folderUnlocked);
_encryptedFolderMetadataHandler->unlockFolder();
}

bool PropagateUploadEncrypted::isUnlockRunning() const
{
return _fetchAndUploadE2eeFolderMetadataJob->isUnlockRunning();
return _encryptedFolderMetadataHandler->isUnlockRunning();
}

bool PropagateUploadEncrypted::isFolderLocked() const
{
return _fetchAndUploadE2eeFolderMetadataJob->isFolderLocked();
return _encryptedFolderMetadataHandler->isFolderLocked();
}

const QByteArray PropagateUploadEncrypted::folderToken() const
{
return _fetchAndUploadE2eeFolderMetadataJob ? _fetchAndUploadE2eeFolderMetadataJob->folderToken() : QByteArray{};
return _encryptedFolderMetadataHandler ? _encryptedFolderMetadataHandler->folderToken() : QByteArray{};
}

void PropagateUploadEncrypted::slotFetchMetadataJobFinished(int statusCode, const QString &message)
Expand All @@ -99,7 +99,7 @@ void PropagateUploadEncrypted::slotFetchMetadataJobFinished(int statusCode, cons
return;
}

const auto metadata = _fetchAndUploadE2eeFolderMetadataJob->folderMetadata();
const auto metadata = _encryptedFolderMetadataHandler->folderMetadata();

if (!metadata || !metadata->isValid()) {
qCDebug(lcPropagateUploadEncrypted()) << "There was an error encrypting the file, aborting upload. Invalid metadata.";
Expand Down Expand Up @@ -172,14 +172,14 @@ void PropagateUploadEncrypted::slotFetchMetadataJobFinished(int statusCode, cons

qCDebug(lcPropagateUploadEncrypted) << "Metadata created, sending to the server.";

connect(_fetchAndUploadE2eeFolderMetadataJob.data(), &EncryptedFolderMetadataHandler::uploadFinished, this, &PropagateUploadEncrypted::slotUploadMetadataFinished);
_fetchAndUploadE2eeFolderMetadataJob->uploadMetadata(true);
connect(_encryptedFolderMetadataHandler.data(), &EncryptedFolderMetadataHandler::uploadFinished, this, &PropagateUploadEncrypted::slotUploadMetadataFinished);
_encryptedFolderMetadataHandler->uploadMetadata(true);
}

void PropagateUploadEncrypted::slotUploadMetadataFinished(int statusCode, const QString &message)
{
if (statusCode != 200) {
qCDebug(lcPropagateUploadEncrypted) << "Update metadata error for folder" << _fetchAndUploadE2eeFolderMetadataJob->folderId() << "with error" << message;
qCDebug(lcPropagateUploadEncrypted) << "Update metadata error for folder" << _encryptedFolderMetadataHandler->folderId() << "with error" << message;
qCDebug(lcPropagateUploadEncrypted()) << "Unlocking the folder.";
emit error();
return;
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/propagateuploadencrypted.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private slots:
QString _remoteParentAbsolutePath;
// TODO: Create a base class with this member in 'protected' and virtual slots for fetch/upload, then refactor this and other similar classes to inherit the
// base class
QScopedPointer<EncryptedFolderMetadataHandler> _fetchAndUploadE2eeFolderMetadataJob;
QScopedPointer<EncryptedFolderMetadataHandler> _encryptedFolderMetadataHandler;
};


Expand Down
Loading

0 comments on commit 06e6aa1

Please sign in to comment.