Fix detection of no mountable disks available.

This commit is contained in:
dlandon
2024-05-12 20:11:31 -05:00
parent 894bc28aaa
commit 414dddb008
3 changed files with 46 additions and 3 deletions

View File

@@ -16,8 +16,23 @@ Cond="_var($var,'fsState')!='Stopped' && _var($var,'shareUser')=='e'"
*/
?>
<?
// Function to filter out unwanted disks and check if any valid disks exist.
function checkDisks($disks) {
foreach ($disks as $disk) {
// Check the disk type and fsStatus.
if (!in_array($disk['name'], ['flash', 'parity', 'parity2']) && $disk['fsStatus'] !== "Unmountable: unsupported or no file system") {
// A valid disk is found, return true.
return true;
}
}
// No valid disks found, return false.
return false;
}
/* Are there any array disks? */
$nodisks = empty(parse_ini_file('state/disks.ini',true)) ? "disabled" : "";
$disks = parse_ini_file('state/disks.ini',true) ?? [];
$nodisks = checkDisks($disks) ? "" : "disabled";
?>
<table class="unraid share_status">

View File

@@ -30,7 +30,7 @@ $sec_nfs = parse_ini_file('state/sec_nfs.ini',true);
// exit when no mountable array disks
$nodisks = "<tr><td class='empty' colspan='7'><strong>"._('There are no mountable array or pool disks - cannot add shares').".</strong></td></tr>";
if (!$disks) die($nodisks);
if (!checkDisks($disks)) die($nodisks);
// No shared disks
$nodisks = "<tr><td class='empty' colspan='7'><i class='fa fa-folder-open-o icon'></i>"._('There are no exportable disk shares')."</td></tr>";
@@ -38,6 +38,20 @@ $nodisks = "<tr><td class='empty' colspan='7'><i class='fa fa-folder-open-o icon
// GUI settings
extract(parse_plugin_cfg('dynamix',true));
// Function to filter out unwanted disks and check if any valid disks exist.
function checkDisks($disks) {
foreach ($disks as $disk) {
// Check the disk type and fsStatus.
if (!in_array($disk['name'], ['flash', 'parity', 'parity2']) && $disk['fsStatus'] !== "Unmountable: unsupported or no file system") {
// A valid disk is found, return true.
return true;
}
}
// No valid disks found, return false.
return false;
}
// Display export settings
function disk_share_settings($protocol,$share) {
if (empty($share)) return;

View File

@@ -48,7 +48,7 @@ $sec_nfs = parse_ini_file('state/sec_nfs.ini',true);
// exit when no mountable array disks
$nodisks = "<tr><td class='empty' colspan='7'><strong>"._('There are no mountable array or pool disks - cannot add shares').".</strong></td></tr>";
if (!$disks) die($nodisks);
if (!checkDisks($disks)) die($nodisks);
// exit when no shares
$noshares = "<tr><td class='empty' colspan='7'><i class='fa fa-folder-open-o icon'></i>"._('There are no exportable user shares')."</td></tr>";
@@ -63,6 +63,20 @@ $pools = implode(',', $pools_check);
// Natural sorting of share names
uksort($shares,'strnatcasecmp');
// Function to filter out unwanted disks and check if any valid disks exist.
function checkDisks($disks) {
foreach ($disks as $disk) {
// Check the disk type and fsStatus.
if (!in_array($disk['name'], ['flash', 'parity', 'parity2']) && $disk['fsStatus'] !== "Unmountable: unsupported or no file system") {
// A valid disk is found, return true.
return true;
}
}
// No valid disks found, return false.
return false;
}
// Display export settings
function user_share_settings($protocol,$share) {
if (empty($share)) return;