make test optional
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
2025-07-20 08:37:32 -05:00
parent 7a9ac2f063
commit 40409fcc4a
2 changed files with 79 additions and 89 deletions

View File

@@ -119,7 +119,10 @@ handlers::handlers(mgmt_app_config *config, httplib::Server *server)
setsockopt(sock, SOL_SOCKET, SO_EXCLUSIVEADDRUSE,
reinterpret_cast<const char *>(&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<const char *>(&opt), sizeof(opt));
#endif // defined(_WIN32)

View File

@@ -21,7 +21,6 @@ class _AddMountScreenState extends State<AddMountScreen> {
Mount? _mount;
final _mountNameController = TextEditingController();
String _mountType = "";
bool _allowAdd = false;
final Map<String, Map<String, dynamic>> _settings = {
"": {},
@@ -71,11 +70,9 @@ class _AddMountScreenState extends State<AddMountScreen> {
DropdownButton<String>(
autofocus: true,
value: _mountType,
onChanged:
(mountType) =>
onChanged: (mountType) =>
_handleChange(auth, mountType ?? ''),
items:
constants.providerTypeList
items: constants.providerTypeList
.map<DropdownMenuItem<String>>((item) {
return DropdownMenuItem<String>(
value: item,
@@ -125,7 +122,6 @@ class _AddMountScreenState extends State<AddMountScreen> {
child: MountSettingsWidget(
isAdd: true,
mount: _mount!,
onChanged: () => setState(() => _allowAdd = false),
settings: _settings[_mountType]!,
showAdvanced: false,
),
@@ -135,7 +131,12 @@ class _AddMountScreenState extends State<AddMountScreen> {
const SizedBox(height: constants.padding),
Row(
children: [
if (_allowAdd) ...[
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),
@@ -193,13 +194,6 @@ class _AddMountScreenState extends State<AddMountScreen> {
},
),
],
if (!_allowAdd)
ElevatedButton.icon(
label: const Text('Test'),
icon: const Icon(Icons.check),
onPressed: _handleProviderTest,
),
],
),
],
],
@@ -221,8 +215,7 @@ class _AddMountScreenState extends State<AddMountScreen> {
_mountNameController.text = mountType == 'Sia' ? 'default' : '';
}
_mount =
(_mountNameController.text.isEmpty)
_mount = (_mountNameController.text.isEmpty)
? null
: Mount(
auth,
@@ -242,17 +235,11 @@ class _AddMountScreenState extends State<AddMountScreen> {
return;
}
if (_allowAdd) {
return;
}
final success = await _mount!.test();
if (!mounted) {
return;
}
setState(() => _allowAdd = success);
displayErrorMessage(
context,
success ? "Success" : "Provider settings are invalid!",