From 40409fcc4ac850a93ac24b688b3623931fc0073a Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Sun, 20 Jul 2025 08:37:32 -0500 Subject: [PATCH] make test optional --- repertory/repertory/src/ui/handlers.cpp | 5 +- .../lib/screens/add_mount_screen.dart | 163 ++++++++---------- 2 files changed, 79 insertions(+), 89 deletions(-) diff --git a/repertory/repertory/src/ui/handlers.cpp b/repertory/repertory/src/ui/handlers.cpp index c6c5f933..f1e3f9e9 100644 --- a/repertory/repertory/src/ui/handlers.cpp +++ b/repertory/repertory/src/ui/handlers.cpp @@ -119,7 +119,10 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server) setsockopt(sock, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, reinterpret_cast(&enable), sizeof(enable)); #else // !defined(_WIN32) - linger opt{1, 0}; + linger opt{ + .l_onoff = 1, + .l_linger = 0, + }; setsockopt(sock, SOL_SOCKET, SO_LINGER, reinterpret_cast(&opt), sizeof(opt)); #endif // defined(_WIN32) diff --git a/web/repertory/lib/screens/add_mount_screen.dart b/web/repertory/lib/screens/add_mount_screen.dart index dd042f3f..5962d2a1 100644 --- a/web/repertory/lib/screens/add_mount_screen.dart +++ b/web/repertory/lib/screens/add_mount_screen.dart @@ -21,7 +21,6 @@ class _AddMountScreenState extends State { Mount? _mount; final _mountNameController = TextEditingController(); String _mountType = ""; - bool _allowAdd = false; final Map> _settings = { "": {}, @@ -71,18 +70,16 @@ class _AddMountScreenState extends State { DropdownButton( autofocus: true, value: _mountType, - onChanged: - (mountType) => - _handleChange(auth, mountType ?? ''), - items: - constants.providerTypeList - .map>((item) { - return DropdownMenuItem( - value: item, - child: Text(item), - ); - }) - .toList(), + onChanged: (mountType) => + _handleChange(auth, mountType ?? ''), + items: constants.providerTypeList + .map>((item) { + return DropdownMenuItem( + value: item, + child: Text(item), + ); + }) + .toList(), ), ], ), @@ -125,7 +122,6 @@ class _AddMountScreenState extends State { child: MountSettingsWidget( isAdd: true, mount: _mount!, - onChanged: () => setState(() => _allowAdd = false), settings: _settings[_mountType]!, showAdvanced: false, ), @@ -135,70 +131,68 @@ class _AddMountScreenState extends State { const SizedBox(height: constants.padding), Row( children: [ - if (_allowAdd) ...[ - ElevatedButton.icon( - label: const Text('Add'), - icon: const Icon(Icons.add), - onPressed: () async { - final mountList = Provider.of(context); + ElevatedButton.icon( + label: const Text('Test'), + icon: const Icon(Icons.check), + onPressed: _handleProviderTest, + ), + const SizedBox(width: constants.padding), + ElevatedButton.icon( + label: const Text('Add'), + icon: const Icon(Icons.add), + onPressed: () async { + final mountList = Provider.of(context); - List failed = []; - if (!validateSettings( - _settings[_mountType]!, - failed, - )) { - for (var key in failed) { - displayErrorMessage( - context, - "Setting '$key' is not valid", - ); - } - return; - } - - if (mountList.hasConfigName( - _mountNameController.text, - )) { - return displayErrorMessage( + List failed = []; + if (!validateSettings( + _settings[_mountType]!, + failed, + )) { + for (var key in failed) { + displayErrorMessage( context, - "Configuration name '${_mountNameController.text}' already exists", + "Setting '$key' is not valid", ); } + return; + } - if (_mountType == "Sia" || _mountType == "S3") { - final bucket = - _settings[_mountType]!["${_mountType}Config"]["Bucket"] - as String; - if (mountList.hasBucketName(_mountType, bucket)) { - return displayErrorMessage( - context, - "Bucket '$bucket' already exists", - ); - } - } - - final success = await mountList.add( - _mountType, - _mountType == 'Remote' - ? '${_settings[_mountType]!['RemoteConfig']['HostNameOrIp']}_${_settings[_mountType]!['RemoteConfig']['ApiPort']}' - : _mountNameController.text, - _settings[_mountType]!, + if (mountList.hasConfigName( + _mountNameController.text, + )) { + return displayErrorMessage( + context, + "Configuration name '${_mountNameController.text}' already exists", ); + } - if (!success || !context.mounted) { - return; + if (_mountType == "Sia" || _mountType == "S3") { + final bucket = + _settings[_mountType]!["${_mountType}Config"]["Bucket"] + as String; + if (mountList.hasBucketName(_mountType, bucket)) { + return displayErrorMessage( + context, + "Bucket '$bucket' already exists", + ); } + } - Navigator.pop(context); - }, - ), - ], - if (!_allowAdd) - ElevatedButton.icon( - label: const Text('Test'), - icon: const Icon(Icons.check), - onPressed: _handleProviderTest, - ), + final success = await mountList.add( + _mountType, + _mountType == 'Remote' + ? '${_settings[_mountType]!['RemoteConfig']['HostNameOrIp']}_${_settings[_mountType]!['RemoteConfig']['ApiPort']}' + : _mountNameController.text, + _settings[_mountType]!, + ); + + if (!success || !context.mounted) { + return; + } + + Navigator.pop(context); + }, + ), ], ), ], @@ -221,19 +215,18 @@ class _AddMountScreenState extends State { _mountNameController.text = mountType == 'Sia' ? 'default' : ''; } - _mount = - (_mountNameController.text.isEmpty) - ? null - : Mount( - auth, - MountConfig( - name: _mountNameController.text, - settings: _settings[mountType], - type: mountType, - ), - null, - isAdd: true, - ); + _mount = (_mountNameController.text.isEmpty) + ? null + : Mount( + auth, + MountConfig( + name: _mountNameController.text, + settings: _settings[mountType], + type: mountType, + ), + null, + isAdd: true, + ); }); } @@ -242,17 +235,11 @@ class _AddMountScreenState extends State { return; } - if (_allowAdd) { - return; - } - final success = await _mount!.test(); if (!mounted) { return; } - setState(() => _allowAdd = success); - displayErrorMessage( context, success ? "Success" : "Provider settings are invalid!",