fix(Settings): better error handling for toggling archive protocol
Enabling the community archive protocol could fail when another app is using the same port that is specified as torrent client port. This would cause the app to crash. With these changes we: 1. No longer crash the app but output an error in the logs 2. We popup a dialog telling the user that the specified pord is in use Closes #7328
This commit is contained in:
parent
98d3073a61
commit
ba4c4b3e93
|
@ -136,7 +136,7 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
|
||||||
result.activityCenterService = activity_center_service.newService(statusFoundation.events, statusFoundation.threadpool)
|
result.activityCenterService = activity_center_service.newService(statusFoundation.events, statusFoundation.threadpool)
|
||||||
result.keycardService = keycard_service.newService(statusFoundation.events, statusFoundation.threadpool)
|
result.keycardService = keycard_service.newService(statusFoundation.events, statusFoundation.threadpool)
|
||||||
result.nodeConfigurationService = node_configuration_service.newService(statusFoundation.fleetConfiguration,
|
result.nodeConfigurationService = node_configuration_service.newService(statusFoundation.fleetConfiguration,
|
||||||
result.settingsService)
|
result.settingsService, statusFoundation.events)
|
||||||
result.keychainService = keychain_service.newService(statusFoundation.events)
|
result.keychainService = keychain_service.newService(statusFoundation.events)
|
||||||
result.accountsService = accounts_service.newService(statusFoundation.events, statusFoundation.threadpool,
|
result.accountsService = accounts_service.newService(statusFoundation.events, statusFoundation.threadpool,
|
||||||
statusFoundation.fleetConfiguration)
|
statusFoundation.fleetConfiguration)
|
||||||
|
|
|
@ -4,6 +4,7 @@ import io_interface
|
||||||
import ../../../../global/app_signals
|
import ../../../../global/app_signals
|
||||||
import ../../../../core/eventemitter
|
import ../../../../core/eventemitter
|
||||||
import ../../../../core/fleets/fleet_configuration
|
import ../../../../core/fleets/fleet_configuration
|
||||||
|
import ../../../../../app_service/service/community/service
|
||||||
import ../../../../../app_service/service/settings/service as settings_service
|
import ../../../../../app_service/service/settings/service as settings_service
|
||||||
import ../../../../../app_service/service/stickers/service as stickers_service
|
import ../../../../../app_service/service/stickers/service as stickers_service
|
||||||
import ../../../../../app_service/service/node_configuration/service as node_configuration_service
|
import ../../../../../app_service/service/node_configuration/service as node_configuration_service
|
||||||
|
@ -33,6 +34,9 @@ proc delete*(self: Controller) =
|
||||||
discard
|
discard
|
||||||
|
|
||||||
proc init*(self: Controller) =
|
proc init*(self: Controller) =
|
||||||
|
self.events.on(SIGNAL_ENABLE_COMMUNITY_ARCHIVE_FAILED) do(e:Args):
|
||||||
|
let args = ErrorArgs(e)
|
||||||
|
self.delegate.enableCommunityHistoryArchiveSupportFailed(args.msg)
|
||||||
discard
|
discard
|
||||||
|
|
||||||
proc getFleet*(self: Controller): string =
|
proc getFleet*(self: Controller): string =
|
||||||
|
|
|
@ -101,3 +101,6 @@ method isCommunityHistoryArchiveSupportEnabled*(self: AccessInterface): bool {.b
|
||||||
|
|
||||||
method toggleCommunityHistoryArchiveSupport*(self: AccessInterface) {.base.} =
|
method toggleCommunityHistoryArchiveSupport*(self: AccessInterface) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method enableCommunityHistoryArchiveSupportFailed*(self: AccessInterface, msg: string) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
|
@ -139,3 +139,7 @@ method toggleCommunityHistoryArchiveSupport*(self: Module) =
|
||||||
|
|
||||||
method isCommunityHistoryArchiveSupportEnabled*(self: Module): bool =
|
method isCommunityHistoryArchiveSupportEnabled*(self: Module): bool =
|
||||||
self.controller.isCommunityHistoryArchiveSupportEnabled()
|
self.controller.isCommunityHistoryArchiveSupportEnabled()
|
||||||
|
|
||||||
|
method enableCommunityHistoryArchiveSupportFailed*(self: Module, msg: string) =
|
||||||
|
self.view.setEnableCommunityHistoryArchiveSupportFailedMsg(msg)
|
||||||
|
self.view.enableCommunityHistoryArchiveSupportFailed()
|
||||||
|
|
|
@ -5,6 +5,7 @@ QtObject:
|
||||||
type
|
type
|
||||||
View* = ref object of QObject
|
View* = ref object of QObject
|
||||||
delegate: io_interface.AccessInterface
|
delegate: io_interface.AccessInterface
|
||||||
|
enableCommunityHistoryArchiveSupportFailedMsg*: string
|
||||||
|
|
||||||
proc delete*(self: View) =
|
proc delete*(self: View) =
|
||||||
self.QObject.delete
|
self.QObject.delete
|
||||||
|
@ -17,6 +18,19 @@ QtObject:
|
||||||
proc load*(self: View) =
|
proc load*(self: View) =
|
||||||
self.delegate.viewDidLoad()
|
self.delegate.viewDidLoad()
|
||||||
|
|
||||||
|
proc enableCommunityHistoryArchiveSupportFailedMsgChanged*(self: View) {.signal.}
|
||||||
|
proc getEnableCommunityHistoryArchiveSupportFailedMsg*(self: View): string {.slot.} =
|
||||||
|
return self.enableCommunityHistoryArchiveSupportFailedMsg
|
||||||
|
QtProperty[string] enableCommunityHistoryArchiveSupportFailedMsg:
|
||||||
|
read = getEnableCommunityHistoryArchiveSupportFailedMsg
|
||||||
|
notify = enableCommunityHistoryArchiveSupportFailedMsgChanged
|
||||||
|
|
||||||
|
proc setEnableCommunityHistoryArchiveSupportFailedMsg*(self: View, msg: string) {.slot.} =
|
||||||
|
self.enableCommunityHistoryArchiveSupportFailedMsg = msg
|
||||||
|
self.enableCommunityHistoryArchiveSupportFailedMsgChanged()
|
||||||
|
|
||||||
|
proc enableCommunityHistoryArchiveSupportFailed*(self: View) {.signal.}
|
||||||
|
|
||||||
proc fleetChanged*(self: View) {.signal.}
|
proc fleetChanged*(self: View) {.signal.}
|
||||||
proc getFleet*(self: View): string {.slot.} =
|
proc getFleet*(self: View): string {.slot.} =
|
||||||
return self.delegate.getFleet()
|
return self.delegate.getFleet()
|
||||||
|
|
|
@ -119,6 +119,8 @@ const SIGNAL_CURATED_COMMUNITY_FOUND* = "curatedCommunityFound"
|
||||||
const SIGNAL_COMMUNITY_MUTED* = "communityMuted"
|
const SIGNAL_COMMUNITY_MUTED* = "communityMuted"
|
||||||
const SIGNAL_CATEGORY_MUTED* = "categoryMuted"
|
const SIGNAL_CATEGORY_MUTED* = "categoryMuted"
|
||||||
const SIGNAL_CATEGORY_UNMUTED* = "categoryUnmuted"
|
const SIGNAL_CATEGORY_UNMUTED* = "categoryUnmuted"
|
||||||
|
|
||||||
|
const SIGNAL_ENABLE_COMMUNITY_ARCHIVE_FAILED* = "enableCommunityHistoryArchiveSupportFailed"
|
||||||
const SIGNAL_DISCORD_CATEGORIES_AND_CHANNELS_EXTRACTED* = "discordCategoriesAndChannelsExtracted"
|
const SIGNAL_DISCORD_CATEGORIES_AND_CHANNELS_EXTRACTED* = "discordCategoriesAndChannelsExtracted"
|
||||||
const SIGNAL_DISCORD_COMMUNITY_IMPORT_FINISHED* = "discordCommunityImportFinished"
|
const SIGNAL_DISCORD_COMMUNITY_IMPORT_FINISHED* = "discordCommunityImportFinished"
|
||||||
const SIGNAL_DISCORD_COMMUNITY_IMPORT_PROGRESS* = "discordCommunityImportProgress"
|
const SIGNAL_DISCORD_COMMUNITY_IMPORT_PROGRESS* = "discordCommunityImportProgress"
|
||||||
|
|
|
@ -2,6 +2,8 @@ import chronicles, json, strutils
|
||||||
|
|
||||||
import ./dto/node_config
|
import ./dto/node_config
|
||||||
import ../settings/service as settings_service
|
import ../settings/service as settings_service
|
||||||
|
import ../community/service
|
||||||
|
import ../../../app/core/eventemitter
|
||||||
import ../../../app/core/fleets/fleet_configuration
|
import ../../../app/core/fleets/fleet_configuration
|
||||||
import ../../../backend/node_config as status_node_config
|
import ../../../backend/node_config as status_node_config
|
||||||
|
|
||||||
|
@ -16,19 +18,25 @@ const BLOOM_LEVEL_NORMAL* = "normal"
|
||||||
const BLOOM_LEVEL_FULL* = "full"
|
const BLOOM_LEVEL_FULL* = "full"
|
||||||
const BLOOM_LEVEL_LIGHT* = "light"
|
const BLOOM_LEVEL_LIGHT* = "light"
|
||||||
|
|
||||||
|
type
|
||||||
|
ErrorArgs* = ref object of Args
|
||||||
|
msg*: string
|
||||||
|
|
||||||
type
|
type
|
||||||
Service* = ref object of RootObj
|
Service* = ref object of RootObj
|
||||||
configuration: NodeConfigDto
|
configuration: NodeConfigDto
|
||||||
fleetConfiguration: FleetConfiguration
|
fleetConfiguration: FleetConfiguration
|
||||||
settingsService: settings_service.Service
|
settingsService: settings_service.Service
|
||||||
|
events: EventEmitter
|
||||||
|
|
||||||
proc delete*(self: Service) =
|
proc delete*(self: Service) =
|
||||||
discard
|
discard
|
||||||
|
|
||||||
proc newService*(fleetConfiguration: FleetConfiguration, settingsService: settings_service.Service): Service =
|
proc newService*(fleetConfiguration: FleetConfiguration, settingsService: settings_service.Service, events: EventEmitter): Service =
|
||||||
result = Service()
|
result = Service()
|
||||||
result.fleetConfiguration = fleetConfiguration
|
result.fleetConfiguration = fleetConfiguration
|
||||||
result.settingsService = settingsService
|
result.settingsService = settingsService
|
||||||
|
result.events = events
|
||||||
|
|
||||||
proc adaptNodeSettingsForTheAppNeed(self: Service) =
|
proc adaptNodeSettingsForTheAppNeed(self: Service) =
|
||||||
self.configuration.DataDir = "./ethereum"
|
self.configuration.DataDir = "./ethereum"
|
||||||
|
@ -65,13 +73,17 @@ proc saveConfiguration(self: Service, configuration: NodeConfigDto): bool =
|
||||||
return true
|
return true
|
||||||
|
|
||||||
method enableCommunityHistoryArchiveSupport*(self: Service): bool =
|
method enableCommunityHistoryArchiveSupport*(self: Service): bool =
|
||||||
let response = status_node_config.enableCommunityHistoryArchiveSupport()
|
try:
|
||||||
if(not response.error.isNil):
|
let response = status_node_config.enableCommunityHistoryArchiveSupport()
|
||||||
error "error enabling community history archive support: ", errDescription = response.error.message
|
if(not response.error.isNil):
|
||||||
return false
|
error "error enabling community history archive support: ", errDescription = response.error.message
|
||||||
|
return false
|
||||||
|
|
||||||
self.fetchNodeConfig()
|
self.fetchNodeConfig()
|
||||||
return true
|
return true
|
||||||
|
except Exception as e:
|
||||||
|
error "Error enabling community history archive support", msg = e.msg
|
||||||
|
self.events.emit(SIGNAL_ENABLE_COMMUNITY_ARCHIVE_FAILED, ErrorArgs(msg: e.msg))
|
||||||
|
|
||||||
method disableCommunityHistoryArchiveSupport*(self: Service): bool =
|
method disableCommunityHistoryArchiveSupport*(self: Service): bool =
|
||||||
let response = status_node_config.disableCommunityHistoryArchiveSupport()
|
let response = status_node_config.disableCommunityHistoryArchiveSupport()
|
||||||
|
|
|
@ -14,6 +14,7 @@ QtObject {
|
||||||
property bool isAutoMessageEnabled: advancedModule? advancedModule.isAutoMessageEnabled : false
|
property bool isAutoMessageEnabled: advancedModule? advancedModule.isAutoMessageEnabled : false
|
||||||
property bool isDebugEnabled: advancedModule? advancedModule.isDebugEnabled : false
|
property bool isDebugEnabled: advancedModule? advancedModule.isDebugEnabled : false
|
||||||
property bool isCommunityHistoryArchiveSupportEnabled: advancedModule? advancedModule.isCommunityHistoryArchiveSupportEnabled : false
|
property bool isCommunityHistoryArchiveSupportEnabled: advancedModule? advancedModule.isCommunityHistoryArchiveSupportEnabled : false
|
||||||
|
property string enableCommunityHistoryArchiveSupportFailedMsg: advancedModule ? advancedModule.enableCommunityHistoryArchiveSupportFailedMsg : ""
|
||||||
|
|
||||||
property var customNetworksModel: advancedModule? advancedModule.customNetworksModel : []
|
property var customNetworksModel: advancedModule? advancedModule.customNetworksModel : []
|
||||||
|
|
||||||
|
@ -36,6 +37,17 @@ QtObject {
|
||||||
readonly property string discordImportTool: "discordImportTool"
|
readonly property string discordImportTool: "discordImportTool"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readonly property Connections connections: Connections {
|
||||||
|
target: advancedModule
|
||||||
|
function onEnableCommunityHistoryArchiveSupportFailed() {
|
||||||
|
root.enableCommunityHistoryArchiveSupportFailed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
signal enableCommunityHistoryArchiveSupportFailed()
|
||||||
|
|
||||||
|
|
||||||
function logDir() {
|
function logDir() {
|
||||||
if(!root.advancedModule)
|
if(!root.advancedModule)
|
||||||
return ""
|
return ""
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import QtQuick 2.13
|
import QtQuick 2.13
|
||||||
import QtQuick.Controls 2.13
|
import QtQuick.Controls 2.13
|
||||||
|
import QtQml.Models 2.14
|
||||||
import QtQuick.Layouts 1.13
|
import QtQuick.Layouts 1.13
|
||||||
import QtGraphicalEffects 1.13
|
import QtGraphicalEffects 1.13
|
||||||
|
|
||||||
|
@ -10,6 +11,8 @@ import shared.popups 1.0
|
||||||
import shared.status 1.0
|
import shared.status 1.0
|
||||||
|
|
||||||
import StatusQ.Core 0.1
|
import StatusQ.Core 0.1
|
||||||
|
import StatusQ.Popups.Dialog 0.1
|
||||||
|
import StatusQ.Controls 0.1
|
||||||
|
|
||||||
import "../stores"
|
import "../stores"
|
||||||
import "../controls"
|
import "../controls"
|
||||||
|
@ -536,5 +539,38 @@ SettingsContentBase {
|
||||||
close()
|
close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: advancedStore
|
||||||
|
function onEnableCommunityHistoryArchiveSupportFailed() {
|
||||||
|
if (root.advancedStore.enableCommunityHistoryArchiveSupportFailedMsg !== "") {
|
||||||
|
Global.openPopup(errorMessageDialogCmp, {
|
||||||
|
errorMessage: root.advancedStore.enableCommunityHistoryArchiveSupportFailedMsg
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: errorMessageDialogCmp
|
||||||
|
StatusDialog {
|
||||||
|
id: errorMessageDialog
|
||||||
|
property string errorMessage: ""
|
||||||
|
title: qsTr("An error occoured")
|
||||||
|
|
||||||
|
StatusBaseText {
|
||||||
|
anchors.fill: parent
|
||||||
|
text: {
|
||||||
|
if (errorMessageDialog.errorMessage.indexOf("address already in use") > -1) {
|
||||||
|
return qsTr("The specified torrent client port is already in use.")
|
||||||
|
}
|
||||||
|
return errorMessageDialog.errorMessage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
standardButtons: Dialog.Ok
|
||||||
|
onAccepted: errorMessageDialog.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue