From f56f8a3f5d8ec6cac0f1c6c0132bc2261cd84d27 Mon Sep 17 00:00:00 2001 From: dlandon Date: Tue, 24 Dec 2024 14:40:43 -0600 Subject: [PATCH] Default to first pool when array is missing on a share that was originally an array. --- emhttp/plugins/dynamix/ShareEdit.page | 3 +-- emhttp/plugins/dynamix/include/ShareList.php | 9 +++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/emhttp/plugins/dynamix/ShareEdit.page b/emhttp/plugins/dynamix/ShareEdit.page index 197d05127..5511b8928 100644 --- a/emhttp/plugins/dynamix/ShareEdit.page +++ b/emhttp/plugins/dynamix/ShareEdit.page @@ -63,7 +63,6 @@ if ((!$poolsOnly) && ($share['useCache'] == "no")) { /* Check for non existent pool device. */ if (($share['cachePool'] && !in_array($share['cachePool'], $pools))) { - $share['useCache'] = $share['cachePool2'] ? "yes" : ($poolsOnly ? "no" : "yes"); $poolDefined = false; } else { @@ -1329,7 +1328,7 @@ $(function() { initDropdown(true); - $('#tab1').bind({ + $('#tab1').on({ click: function() { initDropdown(true); } diff --git a/emhttp/plugins/dynamix/include/ShareList.php b/emhttp/plugins/dynamix/include/ShareList.php index 79e6cba3e..aa633dbc7 100644 --- a/emhttp/plugins/dynamix/include/ShareList.php +++ b/emhttp/plugins/dynamix/include/ShareList.php @@ -187,10 +187,15 @@ define('LUKS_STATUS_UNENCRYPTED', 2); // Build table $row = 0; + +/* Get the first pool if needed. */ +$firstPool = $pools_check[0] ?? ""; foreach ($shares as $name => $share) { /* Correct a situation in previous Unraid versions where an array only share has a useCache defined. */ if ((!$poolsOnly) && ($share['useCache'] == "no")) { $share['cachePool'] = ""; + } else if (($poolsOnly) && (!$share['cachePool'])) { + $share['cachePool'] = $firstPool; } /* Is cachePool2 defined? If it is we need to show the cache pool 2 device name instead of 'Array'. */ @@ -219,8 +224,8 @@ foreach ($shares as $name => $share) { $share_valid = true; } - /* When there is no array, all pools are treated as 'only' cache. If useCache is "no" with an array, this is invalid and useCache has to be 'only'. */ - if ((($poolsOnly) && (! $share['cachePool2'])) || ((! $poolsOnly) && ($share['cachePool']) && ($share['useCache'] == "no"))) { + /* When there is no array, all pools are treated as 'only' cache. */ + if (($poolsOnly) && (! $share['cachePool2'])) { $share['useCache'] = 'only'; }