Default to first pool when array is missing on a share that was originally an array.

This commit is contained in:
dlandon
2024-12-24 14:40:43 -06:00
parent 1fdd8402a5
commit f56f8a3f5d
2 changed files with 8 additions and 4 deletions

View File

@@ -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() {
<?endif;?>
initDropdown(true);
<?if ($tabbed):?>
$('#tab1').bind({
$('#tab1').on({
click: function() {
initDropdown(true);
}

View File

@@ -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';
}