Skip to content

Commit

Permalink
Fix crash
Browse files Browse the repository at this point in the history
Fixes: #9600
  • Loading branch information
TheOneRing committed Apr 26, 2022
1 parent c5cc5a6 commit 8d0dd36
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 13 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/9600
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Crash when interacting with a folder in an error state

We fixed a crash wher using the context menu on a folder that encountered an error and was not using virutal files.

https://github.com/owncloud/client/issues/9600
24 changes: 17 additions & 7 deletions src/gui/folder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ int Folder::slotWipeErrorBlacklist()

void Folder::slotWatchedPathChanged(const QString &path, ChangeReason reason)
{
Q_ASSERT(isReady());
if (!FileSystem::isChildPathOf(path, this->path())) {
qCDebug(lcFolder) << "Changed path is not contained in folder, ignoring:" << path;
return;
Expand Down Expand Up @@ -809,22 +810,25 @@ void Folder::removeFromSettings() const

bool Folder::isFileExcludedAbsolute(const QString &fullPath) const
{
if (!_engine) {
return true;
}
return _engine->excludedFiles().isExcluded(fullPath, path(), _definition.ignoreHiddenFiles);
}

bool Folder::isFileExcludedRelative(const QString &relativePath) const
{
return _engine->excludedFiles().isExcluded(path() + relativePath, path(), _definition.ignoreHiddenFiles);
return isFileExcludedAbsolute(path() + relativePath);
}

void Folder::slotTerminateSync()
{
qCInfo(lcFolder) << "folder " << alias() << " Terminating!";

if (_engine->isSyncRunning()) {
_engine->abort();

setSyncState(SyncResult::SyncAbortRequested);
if (isReady()) {
qCInfo(lcFolder) << "folder " << alias() << " Terminating!";
if (_engine->isSyncRunning()) {
_engine->abort();
setSyncState(SyncResult::SyncAbortRequested);
}
}
}

Expand Down Expand Up @@ -875,6 +879,9 @@ void Folder::wipeForRemoval()

bool Folder::reloadExcludes()
{
if (!_engine) {
return true;
}
return _engine->excludedFiles().reloadExcludeFiles();
}

Expand Down Expand Up @@ -941,6 +948,7 @@ void Folder::startSync()

void Folder::setSyncOptions()
{
Q_ASSERT(isReady());
SyncOptions opt;
ConfigFile cfgFile;

Expand All @@ -964,6 +972,7 @@ void Folder::setSyncOptions()

void Folder::setDirtyNetworkLimits()
{
Q_ASSERT(isReady());
ConfigFile cfg;
int downloadLimit = -75; // 75%
int useDownLimit = cfg.useDownloadLimit();
Expand Down Expand Up @@ -999,6 +1008,7 @@ void Folder::slotSyncStarted()

void Folder::slotSyncFinished(bool success)
{
Q_ASSERT(isReady());
qCInfo(lcFolder) << "Client version" << Theme::instance()->aboutVersions(Theme::VersionFormat::OneLiner);

bool syncError = !_syncResult.errorStrings().isEmpty();
Expand Down
12 changes: 10 additions & 2 deletions src/gui/folder.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,16 @@ class Folder : public QObject
void setIgnoreHiddenFiles(bool ignore);

// Used by the Socket API
SyncJournalDb *journalDb() { return &_journal; }
SyncEngine &syncEngine() { return *_engine; }
SyncJournalDb *journalDb()
{
Q_ASSERT(isReady());
return &_journal;
}
SyncEngine &syncEngine()
{
Q_ASSERT(isReady());
return *_engine;
}
Vfs &vfs()
{
OC_ENFORCE(_vfs);
Expand Down
3 changes: 3 additions & 0 deletions src/gui/folderstatusmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,9 @@ bool FolderStatusModel::canFetchMore(const QModelIndex &parent) const

void FolderStatusModel::fetchMore(const QModelIndex &parent)
{
if (!data(parent, FolderStatusDelegate::IsReady).toBool()) {
return;
}
auto info = infoForIndex(parent);

if (!info || info->_fetched || info->_fetchingJob)
Expand Down
10 changes: 6 additions & 4 deletions src/gui/ignorelisteditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ void IgnoreListEditor::slotUpdateLocalIgnoreList()
// Otherwise we would not download the files/directories that are no longer
// ignored (because the remote etag did not change) (issue #3172)
for (auto *folder : folderMan->map()) {
folder->journalDb()->forceRemoteDiscoveryNextSync();
folder->reloadExcludes();
folder->slotNextSyncFullLocalDiscovery();
folderMan->scheduleFolder(folder);
if (folder->isReady()) {
folder->journalDb()->forceRemoteDiscoveryNextSync();
folder->reloadExcludes();
folder->slotNextSyncFullLocalDiscovery();
folderMan->scheduleFolder(folder);
}
}
}

Expand Down

0 comments on commit 8d0dd36

Please sign in to comment.