Skip to content

Commit

Permalink
Add logs.
Browse files Browse the repository at this point in the history
Signed-off-by: Camila Ayres <[email protected]>
  • Loading branch information
camilasan committed Apr 2, 2024
1 parent ceb43e0 commit 919d9a0
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
if (!folderPaused) {
ac = menu->addAction(tr("Force sync now"));
if (folder && folder->isSyncRunning()) {
qCWarning(lcAccountSettings) << "=> Restart syncing for" << selectedFolderAlias();
ac->setText(tr("Restart sync"));
}
ac->setEnabled(folderConnected);
Expand Down Expand Up @@ -1139,6 +1140,7 @@ void AccountSettings::showConnectionLabel(const QString &message, QStringList er

void AccountSettings::slotEnableCurrentFolder(bool terminate)
{
qCWarning(lcAccountSettings) << "=> User!! resuming or pausing sync: terminate value is" << terminate;
const auto alias = selectedFolderAlias();

if (!alias.isEmpty()) {
Expand Down Expand Up @@ -1195,8 +1197,9 @@ void AccountSettings::slotScheduleCurrentFolder()

void AccountSettings::slotScheduleCurrentFolderForceRemoteDiscovery()
{
const auto folderMan = FolderMan::instance();
const auto folderMan = FolderMan::instance();

Check warning on line 1200 in src/gui/accountsettings.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/accountsettings.cpp:1200:5 [readability-qualified-auto]

'const auto folderMan' can be declared as 'auto *const folderMan'
if (auto folder = folderMan->folder(selectedFolderAlias())) {
qCWarning(lcAccountSettings) << "=> Schedule current folder" << selectedFolderAlias() << "RemoteDiscovery";
folder->slotWipeErrorBlacklist();
folder->journalDb()->forceRemoteDiscoveryNextSync();
folderMan->scheduleFolder(folder);
Expand All @@ -1207,6 +1210,7 @@ void AccountSettings::slotForceSyncCurrentFolder()
{
FolderMan *folderMan = FolderMan::instance();
auto selectedFolder = folderMan->folder(selectedFolderAlias());
qCWarning(lcAccountSettings) << "=> Force syncing for" << selectedFolderAlias();
folderMan->forceSyncForFolder(selectedFolder);
}

Expand Down
1 change: 1 addition & 0 deletions src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ void Application::slotAccountStateAdded(AccountState *accountState)

void Application::slotCleanup()
{
qCWarning(lcApplication) << "=> User!! Application is about to quite/close!!";
AccountManager::instance()->save();
FolderMan::instance()->unloadAndDeleteAllFolders();

Expand Down
2 changes: 2 additions & 0 deletions src/gui/connectionvalidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ void ConnectionValidator::slotAuthFailed(QNetworkReply *reply)
auto job = qobject_cast<PropfindJob *>(sender());
Status stat = Timeout;

qCWarning(lcConnectionValidator) << "=> reply->error():" << reply->error() << "- job->errorString():" << job->errorString();

if (reply->error() == QNetworkReply::SslHandshakeFailedError) {
_errors << job->errorStringParsingBody();
stat = SslError;
Expand Down
2 changes: 2 additions & 0 deletions src/gui/folder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ void Folder::etagRetrieved(const QByteArray &etag, const QDateTime &tp)
{
// re-enable sync if it was disabled because network was down
FolderMan::instance()->setSyncEnabled(true);
qCInfo(lcFolder) << "=> Etag retrieved: last:" << _lastEtag << ", received:" << etag;
qCInfo(lcFolder) << "=> For folder:" << _canonicalLocalPath;

if (_lastEtag != etag) {
qCInfo(lcFolder) << "Compare etag with previous etag: last:" << _lastEtag << ", received:" << etag << "-> CHANGED";
Expand Down
6 changes: 5 additions & 1 deletion src/gui/folderman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ void FolderMan::forceSyncForFolder(Folder *folder)
// Terminate and reschedule any running sync
for (const auto folderInMap : map()) {
if (folderInMap->isSyncRunning()) {
qCWarning(lcFolderMan) << "=> User!! Terminating syncing for" << folderInMap->path();
folderInMap->slotTerminateSync();
scheduleFolder(folderInMap);
}
Expand All @@ -679,7 +680,7 @@ void FolderMan::removeE2eFiles(const AccountPtr &account) const
void FolderMan::slotScheduleAppRestart()
{
_appRestartRequired = true;
qCInfo(lcFolderMan) << "Application restart requested!";
qCInfo(lcFolderMan) << "=> Application restart requested!";
}

void FolderMan::slotSyncOnceFileUnlocks(const QString &path)
Expand Down Expand Up @@ -1339,6 +1340,7 @@ void FolderMan::removeFolder(Folder *f)
const bool currentlyRunning = f->isSyncRunning();
if (currentlyRunning) {
// abort the sync now
qCWarning(lcFolderMan) << "=> User?? Abort syncing for" << f->path();
f->slotTerminateSync();
}

Expand Down Expand Up @@ -1929,6 +1931,8 @@ Folder *FolderMan::currentSyncFolder() const

void FolderMan::restartApplication()
{
qCInfo(lcFolderMan) << "Restarting application NOW!!";

if (Utility::isLinux()) {
// restart:
qCInfo(lcFolderMan) << "Restarting application NOW, PID" << qApp->applicationPid() << "is ending.";
Expand Down
1 change: 1 addition & 0 deletions src/gui/owncloudgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ void ownCloudGui::slotShutdown()
{
// explicitly close windows. This is somewhat of a hack to ensure
// that saving the geometries happens ASAP during a OS shutdown
qCWarning(lcApplication) << "=> Shutting down!!";

// those do delete on close
if (!_settingsDialog.isNull())
Expand Down
2 changes: 2 additions & 0 deletions src/gui/systray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,13 @@ void Systray::slotCurrentUserChanged()

void Systray::slotUnpauseAllFolders()
{
qCWarning(lcSystray) << "=> User!! Resume/unpause syncing all folders!!";
setPauseOnAllFoldersHelper(false);
}

void Systray::slotPauseAllFolders()
{
qCWarning(lcSystray) << "=> User!! Pause syncing all folders!!";
setPauseOnAllFoldersHelper(true);
}

Expand Down
3 changes: 3 additions & 0 deletions src/gui/tray/usermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ constexpr qint64 activityDefaultExpirationTimeMsecs = 1000 * 60 * 10;
}

namespace OCC {

Q_LOGGING_CATEGORY(lcUserModel, "nextcloud.gui.usermodel", QtInfoMsg)

Check warning on line 40 in src/gui/tray/usermodel.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/tray/usermodel.cpp:40:1 [cppcoreguidelines-avoid-non-const-global-variables]

variable 'Q_LOGGING_CATEGORY' is non-const and globally accessible, consider making it const

TrayFolderInfo::TrayFolderInfo(const QString &name, const QString &parentPath, const QString &fullPath, FolderType folderType)
: _name(name)
Expand Down Expand Up @@ -1098,6 +1100,7 @@ void User::slotSendReplyMessage(const int activityIndex, const QString &token, c

void User::forceSyncNow() const
{
qCWarning(lcUserModel) << "=> Force sync now for" << getFolder()->path();
FolderMan::instance()->forceSyncForFolder(getFolder());
}

Expand Down
2 changes: 2 additions & 0 deletions src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2109,6 +2109,8 @@ void ProcessDirectoryJob::startAsyncLocalQuery()
QString localPath = _discoveryData->_localDir + _currentFolder._local;
auto localJob = new DiscoverySingleLocalDirectoryJob(_discoveryData->_account, localPath, _discoveryData->_syncOptions._vfs.data());

qCWarning(lcDisco) << "=> ProcessDirectoryJob::startAsyncLocalQuery: localPath:" << localPath;

_discoveryData->_currentlyActiveJobs++;
_pendingAsyncJobs++;

Expand Down
7 changes: 7 additions & 0 deletions src/libsync/discoveryphase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ void DiscoveryPhase::checkFolderSizeLimit(const QString &path, const std::functi
<< "http://owncloud.org/ns:size");

connect(propfindJob, &PropfindJob::finishedWithError, this, [=] {
qCWarning(lcDiscovery) << "=> propfindJob->reply()->error():" << propfindJob->reply()->error() << "- propfindJob->reply()->errorString():" << propfindJob->reply()->errorString();
return completionCallback(false);
});
connect(propfindJob, &PropfindJob::result, this, [=](const QVariantMap &values) {
Expand Down Expand Up @@ -228,8 +229,10 @@ void DiscoveryPhase::enqueueDirectoryToDelete(const QString &path, ProcessDirect
void DiscoveryPhase::startJob(ProcessDirectoryJob *job)
{
ENFORCE(!_currentRootJob);
qCWarning(lcDiscovery) << "=> DiscoveryPhase::startJob for:" << job->_dirItem;
connect(this, &DiscoveryPhase::itemDiscovered, this, &DiscoveryPhase::slotItemDiscovered, Qt::UniqueConnection);
connect(job, &ProcessDirectoryJob::finished, this, [this, job] {
qCWarning(lcDiscovery) << "=> ProcessDirectoryJob::finished for" << job->_dirItem;
ENFORCE(_currentRootJob == sender());
_currentRootJob = nullptr;
if (job->_dirItem)
Expand Down Expand Up @@ -276,6 +279,10 @@ void DiscoveryPhase::scheduleMoreJobs()

void DiscoveryPhase::slotItemDiscovered(const OCC::SyncFileItemPtr &item)
{
qCWarning(lcDiscovery) << "=> DiscoveryPhase::slotItemDiscovered:"
<< "| item->_file:" << item->_file
<< "| item->_direction:" << item->_direction
<< "| item->_instruction:" << item->_instruction;
if (item->_instruction == CSYNC_INSTRUCTION_ERROR && item->_direction == SyncFileItem::Up) {
_hasUploadErrorItems = true;
}
Expand Down
6 changes: 4 additions & 2 deletions src/libsync/networkjobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ bool PropfindJob::finished()

if (!domDocument.setContent(reply(), true, &errorMsg, &errorLine, &errorColumn)) {
qCWarning(lcPropfindJob) << "XML parser error: " << errorMsg << errorLine << errorColumn;
qCWarning(lcPropfindJob) << "=> reply()->error():" << reply()->error() << "- reply()->errorString():" << reply()->errorString();
emit finishedWithError(reply());

} else {
Expand All @@ -679,6 +680,7 @@ bool PropfindJob::finished()
} else {
qCWarning(lcPropfindJob) << "*not* successful, http result code is" << http_result_code
<< (http_result_code == 302 ? reply()->header(QNetworkRequest::LocationHeader).toString() : QLatin1String(""));
qCWarning(lcPropfindJob) << "=> reply()->error():" << reply()->error() << "- reply()->errorString():" << reply()->errorString();
emit finishedWithError(reply());
}

Expand Down Expand Up @@ -1270,8 +1272,8 @@ void fetchPrivateLinkUrl(AccountPtr account, const QString &remotePath,
targetFun(oldUrl);
}
});
QObject::connect(job, &PropfindJob::finishedWithError, target, [=](QNetworkReply *) {
targetFun(oldUrl);
QObject::connect(job, &PropfindJob::finishedWithError, target, [=](QNetworkReply * reply) {
qCWarning(lcPropfindJob) << "=> reply->error():" << reply->error() << "- job->errorString():" << job->errorString();
});
job->start();
}
Expand Down
1 change: 1 addition & 0 deletions src/libsync/propagateremotemkdir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ void PropagateRemoteMkdir::finalizeMkColJob(QNetworkReply::NetworkError err, con
});
connect(propfindJob, &PropfindJob::finishedWithError, this, [this] (QNetworkReply *reply) {
const auto err = reply ? reply->error() : QNetworkReply::NetworkError::UnknownNetworkError;
qCWarning(lcPropagateRemoteMkdir) << "=> reply->error():" << reply->error() << "- propfindJob->errorString():" << reply->errorString();
propagator()->_activeJobList.removeOne(this);
done(SyncFileItem::NormalError, {}, errorCategoryFromNetworkError(err));
});
Expand Down
1 change: 1 addition & 0 deletions src/libsync/syncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ void SyncEngine::startSync()
connect(_discoveryPhase.data(), &DiscoveryPhase::existingFolderNowBig, this, &SyncEngine::existingFolderNowBig);
connect(_discoveryPhase.data(), &DiscoveryPhase::fatalError, this, [this](const QString &errorString, ErrorCategory errorCategory) {
Q_EMIT syncError(errorString, errorCategory);
qCWarning(lcEngine) << "=> SyncEngine DiscoveryPhase::fatalError emitted:" << errorString;
finalize(false);
});
connect(_discoveryPhase.data(), &DiscoveryPhase::finished, this, &SyncEngine::slotDiscoveryFinished);
Expand Down

0 comments on commit 919d9a0

Please sign in to comment.