CLOUD: Check whether Storage is working when replacing it
We do that in CloudManager::replaceStorage(), but I've tried to eliminate such possibility by adding a check in the StorageWizardDialog.
This commit is contained in:
parent
f743b31963
commit
b1264df120
2 changed files with 31 additions and 1 deletions
|
@ -128,7 +128,14 @@ void CloudManager::replaceStorage(Storage *storage, uint32 index) {
|
|||
freeStorages();
|
||||
if (!storage) error("CloudManager::replaceStorage: NULL storage passed");
|
||||
if (index >= kStorageTotal) error("CloudManager::replaceStorage: invalid index passed");
|
||||
if (_activeStorage != nullptr && _activeStorage->isWorking()) {
|
||||
warning("CloudManager::replaceStorage: replacing Storage while the other is working");
|
||||
if (_activeStorage->isDownloading()) _activeStorage->cancelDownload();
|
||||
if (_activeStorage->isSyncing()) _activeStorage->cancelSync();
|
||||
removeStorage(_activeStorage);
|
||||
} else {
|
||||
delete _activeStorage;
|
||||
}
|
||||
_activeStorage = storage;
|
||||
_currentStorageIndex = index;
|
||||
save();
|
||||
|
|
|
@ -74,6 +74,29 @@ StorageWizardDialog::StorageWizardDialog(uint32 storageId):
|
|||
|
||||
void StorageWizardDialog::open() {
|
||||
Dialog::open();
|
||||
|
||||
if (CloudMan.isWorking()) {
|
||||
bool doClose = true;
|
||||
|
||||
MessageDialog alert(_("The other Storage is working. Do you want to interrupt it?"), _("Yes"), _("No"));
|
||||
if (alert.runModal() == GUI::kMessageOK) {
|
||||
if (CloudMan.isDownloading()) CloudMan.cancelDownload();
|
||||
if (CloudMan.isSyncing()) CloudMan.cancelSync();
|
||||
|
||||
// I believe it still would return `true` here, but just in case
|
||||
if (CloudMan.isWorking()) {
|
||||
MessageDialog alert2(_("Wait until current Storage finishes up and try again."));
|
||||
alert2.runModal();
|
||||
} else
|
||||
doClose = false;
|
||||
}
|
||||
|
||||
if (doClose) {
|
||||
close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_SDL_NET
|
||||
_stopServerOnClose = !LocalServer.isRunning();
|
||||
LocalServer.start();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue