mirror of
https://github.com/chylex/Nextcloud-Desktop.git
synced 2025-05-29 10:34:09 +02:00
FolderMan: Remove assumption of unique running sync
This commit is contained in:
parent
22e08cf6ad
commit
c3b1a872aa
@ -426,7 +426,7 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
|
|||||||
|
|
||||||
if (!folderPaused) {
|
if (!folderPaused) {
|
||||||
ac = menu->addAction(tr("Force sync now"));
|
ac = menu->addAction(tr("Force sync now"));
|
||||||
if (folderMan->currentSyncFolder() == folder) {
|
if (folder && folder->isSyncRunning()) {
|
||||||
ac->setText(tr("Restart sync"));
|
ac->setText(tr("Restart sync"));
|
||||||
}
|
}
|
||||||
ac->setEnabled(folderConnected);
|
ac->setEnabled(folderConnected);
|
||||||
@ -738,9 +738,11 @@ void AccountSettings::slotForceSyncCurrentFolder()
|
|||||||
FolderMan *folderMan = FolderMan::instance();
|
FolderMan *folderMan = FolderMan::instance();
|
||||||
if (auto selectedFolder = folderMan->folder(selectedFolderAlias())) {
|
if (auto selectedFolder = folderMan->folder(selectedFolderAlias())) {
|
||||||
// Terminate and reschedule any running sync
|
// Terminate and reschedule any running sync
|
||||||
if (Folder *current = folderMan->currentSyncFolder()) {
|
for (auto f : folderMan->map()) {
|
||||||
folderMan->terminateSyncProcess();
|
if (f->isSyncRunning()) {
|
||||||
folderMan->scheduleFolder(current);
|
f->slotTerminateSync();
|
||||||
|
folderMan->scheduleFolder(f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedFolder->slotWipeErrorBlacklist(); // issue #6757
|
selectedFolder->slotWipeErrorBlacklist(); // issue #6757
|
||||||
|
@ -221,6 +221,11 @@ bool Folder::isBusy() const
|
|||||||
return _engine->isSyncRunning();
|
return _engine->isSyncRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Folder::isSyncRunning() const
|
||||||
|
{
|
||||||
|
return _engine->isSyncRunning();
|
||||||
|
}
|
||||||
|
|
||||||
QString Folder::remotePath() const
|
QString Folder::remotePath() const
|
||||||
{
|
{
|
||||||
return _definition.targetPath;
|
return _definition.targetPath;
|
||||||
|
@ -164,6 +164,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual bool isBusy() const;
|
virtual bool isBusy() const;
|
||||||
|
|
||||||
|
/** True if the folder is currently synchronizing */
|
||||||
|
bool isSyncRunning() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the last sync result with error message and status
|
* return the last sync result with error message and status
|
||||||
*/
|
*/
|
||||||
|
@ -541,19 +541,6 @@ void FolderMan::slotFolderCanSyncChanged()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this really terminates the current sync process
|
|
||||||
// ie. no questions, no prisoners
|
|
||||||
// csync still remains in a stable state, regardless of that.
|
|
||||||
void FolderMan::terminateSyncProcess()
|
|
||||||
{
|
|
||||||
Folder *f = _currentSyncFolder;
|
|
||||||
if (f) {
|
|
||||||
// This will, indirectly and eventually, call slotFolderSyncFinished
|
|
||||||
// and thereby clear _currentSyncFolder.
|
|
||||||
f->slotTerminateSync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Folder *FolderMan::folder(const QString &alias)
|
Folder *FolderMan::folder(const QString &alias)
|
||||||
{
|
{
|
||||||
if (!alias.isEmpty()) {
|
if (!alias.isEmpty()) {
|
||||||
@ -665,7 +652,7 @@ void FolderMan::slotRunOneEtagJob()
|
|||||||
//qCDebug(lcFolderMan) << "No more remote ETag check jobs to schedule.";
|
//qCDebug(lcFolderMan) << "No more remote ETag check jobs to schedule.";
|
||||||
|
|
||||||
/* now it might be a good time to check for restarting... */
|
/* now it might be a good time to check for restarting... */
|
||||||
if (!_currentSyncFolder && _appRestartRequired) {
|
if (!isAnySyncRunning() && _appRestartRequired) {
|
||||||
restartApplication();
|
restartApplication();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -697,9 +684,12 @@ void FolderMan::slotAccountStateChanged()
|
|||||||
qCInfo(lcFolderMan) << "Account" << accountName << "disconnected or paused, "
|
qCInfo(lcFolderMan) << "Account" << accountName << "disconnected or paused, "
|
||||||
"terminating or descheduling sync folders";
|
"terminating or descheduling sync folders";
|
||||||
|
|
||||||
if (_currentSyncFolder
|
foreach (Folder *f, _folderMap.values()) {
|
||||||
&& _currentSyncFolder->accountState() == accountState) {
|
if (f
|
||||||
_currentSyncFolder->slotTerminateSync();
|
&& f->isSyncRunning()
|
||||||
|
&& f->accountState() == accountState) {
|
||||||
|
f->slotTerminateSync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QMutableListIterator<Folder *> it(_scheduledFolders);
|
QMutableListIterator<Folder *> it(_scheduledFolders);
|
||||||
@ -734,7 +724,7 @@ void FolderMan::startScheduledSyncSoon()
|
|||||||
if (_scheduledFolders.empty()) {
|
if (_scheduledFolders.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_currentSyncFolder) {
|
if (isAnySyncRunning()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -772,8 +762,11 @@ void FolderMan::startScheduledSyncSoon()
|
|||||||
*/
|
*/
|
||||||
void FolderMan::slotStartScheduledFolderSync()
|
void FolderMan::slotStartScheduledFolderSync()
|
||||||
{
|
{
|
||||||
if (_currentSyncFolder) {
|
if (isAnySyncRunning()) {
|
||||||
qCInfo(lcFolderMan) << "Currently folder " << _currentSyncFolder->remoteUrl().toString() << " is running, wait for finish!";
|
for (auto f : _folderMap) {
|
||||||
|
if (f->isSyncRunning())
|
||||||
|
qCInfo(lcFolderMan) << "Currently folder " << f->remoteUrl().toString() << " is running, wait for finish!";
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -820,7 +813,7 @@ void FolderMan::slotEtagPollTimerTimeout()
|
|||||||
if (!f) {
|
if (!f) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (_currentSyncFolder == f) {
|
if (f->isSyncRunning()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (_scheduledFolders.contains(f)) {
|
if (_scheduledFolders.contains(f)) {
|
||||||
@ -931,12 +924,29 @@ void FolderMan::slotScheduleFolderByTime()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FolderMan::isAnySyncRunning() const
|
||||||
|
{
|
||||||
|
if (_currentSyncFolder)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
for (auto f : _folderMap) {
|
||||||
|
if (f->isSyncRunning())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void FolderMan::slotFolderSyncStarted()
|
void FolderMan::slotFolderSyncStarted()
|
||||||
{
|
{
|
||||||
|
auto f = qobject_cast<Folder *>(sender());
|
||||||
|
ASSERT(f);
|
||||||
|
if (!f)
|
||||||
|
return;
|
||||||
|
|
||||||
qCInfo(lcFolderMan, ">========== Sync started for folder [%s] of account [%s] with remote [%s]",
|
qCInfo(lcFolderMan, ">========== Sync started for folder [%s] of account [%s] with remote [%s]",
|
||||||
qPrintable(_currentSyncFolder->shortGuiLocalPath()),
|
qPrintable(f->shortGuiLocalPath()),
|
||||||
qPrintable(_currentSyncFolder->accountState()->account()->displayName()),
|
qPrintable(f->accountState()->account()->displayName()),
|
||||||
qPrintable(_currentSyncFolder->remoteUrl().toString()));
|
qPrintable(f->remoteUrl().toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -947,15 +957,22 @@ void FolderMan::slotFolderSyncStarted()
|
|||||||
*/
|
*/
|
||||||
void FolderMan::slotFolderSyncFinished(const SyncResult &)
|
void FolderMan::slotFolderSyncFinished(const SyncResult &)
|
||||||
{
|
{
|
||||||
|
auto f = qobject_cast<Folder *>(sender());
|
||||||
|
ASSERT(f);
|
||||||
|
if (!f)
|
||||||
|
return;
|
||||||
|
|
||||||
qCInfo(lcFolderMan, "<========== Sync finished for folder [%s] of account [%s] with remote [%s]",
|
qCInfo(lcFolderMan, "<========== Sync finished for folder [%s] of account [%s] with remote [%s]",
|
||||||
qPrintable(_currentSyncFolder->shortGuiLocalPath()),
|
qPrintable(f->shortGuiLocalPath()),
|
||||||
qPrintable(_currentSyncFolder->accountState()->account()->displayName()),
|
qPrintable(f->accountState()->account()->displayName()),
|
||||||
qPrintable(_currentSyncFolder->remoteUrl().toString()));
|
qPrintable(f->remoteUrl().toString()));
|
||||||
|
|
||||||
_lastSyncFolder = _currentSyncFolder;
|
if (f == _currentSyncFolder) {
|
||||||
_currentSyncFolder = nullptr;
|
_lastSyncFolder = _currentSyncFolder;
|
||||||
|
_currentSyncFolder = nullptr;
|
||||||
startScheduledSyncSoon();
|
}
|
||||||
|
if (!isAnySyncRunning())
|
||||||
|
startScheduledSyncSoon();
|
||||||
}
|
}
|
||||||
|
|
||||||
Folder *FolderMan::addFolder(AccountState *accountState, const FolderDefinition &folderDefinition)
|
Folder *FolderMan::addFolder(AccountState *accountState, const FolderDefinition &folderDefinition)
|
||||||
@ -1074,10 +1091,10 @@ void FolderMan::removeFolder(Folder *f)
|
|||||||
|
|
||||||
qCInfo(lcFolderMan) << "Removing " << f->alias();
|
qCInfo(lcFolderMan) << "Removing " << f->alias();
|
||||||
|
|
||||||
const bool currentlyRunning = (_currentSyncFolder == f);
|
const bool currentlyRunning = f->isSyncRunning();
|
||||||
if (currentlyRunning) {
|
if (currentlyRunning) {
|
||||||
// abort the sync now
|
// abort the sync now
|
||||||
terminateSyncProcess();
|
f->slotTerminateSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_scheduledFolders.removeAll(f) > 0) {
|
if (_scheduledFolders.removeAll(f) > 0) {
|
||||||
@ -1202,7 +1219,7 @@ void FolderMan::slotWipeFolderForAccount(AccountState *accountState)
|
|||||||
const bool currentlyRunning = (_currentSyncFolder == f);
|
const bool currentlyRunning = (_currentSyncFolder == f);
|
||||||
if (currentlyRunning) {
|
if (currentlyRunning) {
|
||||||
// abort the sync now
|
// abort the sync now
|
||||||
terminateSyncProcess();
|
_currentSyncFolder->slotTerminateSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_scheduledFolders.removeAll(f) > 0) {
|
if (_scheduledFolders.removeAll(f) > 0) {
|
||||||
|
@ -164,9 +164,22 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Access to the currently syncing folder.
|
* Access to the currently syncing folder.
|
||||||
|
*
|
||||||
|
* Note: This is only the folder that's currently syncing *as-scheduled*. There
|
||||||
|
* may be externally-managed syncs such as from placeholder hydrations.
|
||||||
|
*
|
||||||
|
* See also isAnySyncRunning()
|
||||||
*/
|
*/
|
||||||
Folder *currentSyncFolder() const;
|
Folder *currentSyncFolder() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if any folder is currently syncing.
|
||||||
|
*
|
||||||
|
* This might be a FolderMan-scheduled sync, or a externally
|
||||||
|
* managed sync like a placeholder hydration.
|
||||||
|
*/
|
||||||
|
bool isAnySyncRunning() const;
|
||||||
|
|
||||||
/** Removes all folders */
|
/** Removes all folders */
|
||||||
int unloadAndDeleteAllFolders();
|
int unloadAndDeleteAllFolders();
|
||||||
|
|
||||||
@ -188,13 +201,6 @@ public:
|
|||||||
void setDirtyProxy();
|
void setDirtyProxy();
|
||||||
void setDirtyNetworkLimits();
|
void setDirtyNetworkLimits();
|
||||||
|
|
||||||
/**
|
|
||||||
* Terminates the current folder sync.
|
|
||||||
*
|
|
||||||
* It does not switch the folder to paused state.
|
|
||||||
*/
|
|
||||||
void terminateSyncProcess();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* signal to indicate a folder has changed its sync state.
|
* signal to indicate a folder has changed its sync state.
|
||||||
|
@ -1090,9 +1090,9 @@ void FolderStatusModel::slotFolderSyncStateChange(Folder *f)
|
|||||||
} else if (state == SyncResult::NotYetStarted) {
|
} else if (state == SyncResult::NotYetStarted) {
|
||||||
FolderMan *folderMan = FolderMan::instance();
|
FolderMan *folderMan = FolderMan::instance();
|
||||||
int pos = folderMan->scheduleQueue().indexOf(f);
|
int pos = folderMan->scheduleQueue().indexOf(f);
|
||||||
if (folderMan->currentSyncFolder()
|
for (auto other : folderMan->map()) {
|
||||||
&& folderMan->currentSyncFolder() != f) {
|
if (other != f && other->isSyncRunning())
|
||||||
pos += 1;
|
pos += 1;
|
||||||
}
|
}
|
||||||
QString message;
|
QString message;
|
||||||
if (pos <= 0) {
|
if (pos <= 0) {
|
||||||
|
@ -245,7 +245,7 @@ void ownCloudGui::slotComputeOverallSyncStatus()
|
|||||||
// FIXME: So this doesn't do anything? Needs to be revisited
|
// FIXME: So this doesn't do anything? Needs to be revisited
|
||||||
Q_UNUSED(text)
|
Q_UNUSED(text)
|
||||||
// Don't overwrite the status if we're currently syncing
|
// Don't overwrite the status if we're currently syncing
|
||||||
if (FolderMan::instance()->currentSyncFolder())
|
if (FolderMan::instance()->isAnySyncRunning())
|
||||||
return;
|
return;
|
||||||
//_actionStatus->setText(text);
|
//_actionStatus->setText(text);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user