From: Niclas Berglind Date: Tue, 14 Oct 2014 20:25:18 +0000 (+0200) Subject: Added try/catch when using /dev/disk/by-path X-Git-Url: http://git.datanom.net/omvzfs.git/commitdiff_plain/3ed7a24053f0123d8d4e18ef313d83d23181de00 Added try/catch when using /dev/disk/by-path Signed-off-by: Niclas Berglind --- diff --git a/gui/rpc/zfs.inc b/gui/rpc/zfs.inc index 881372a..9ab61a2 100644 --- a/gui/rpc/zfs.inc +++ b/gui/rpc/zfs.inc @@ -81,12 +81,16 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract { $disks = preg_split("/[,;]/", $params['devices']); //Use /dev/disk/by-path as suggested in ZoL FAQ. if ($params['diskpath']) { - if (file_exists("/dev/disk/by-path/")) { - $tmp_disks = array(); - foreach ($disks as $disk) { - $tmp_disks[] = OMVModuleZFSUtil::getDiskPath($disk); + try { + if (file_exists("/dev/disk/by-path/")) { + $tmp_disks = array(); + foreach ($disks as $disk) { + $tmp_disks[] = OMVModuleZFSUtil::getDiskPath($disk); + } + $disks = $tmp_disks; } - $disks = $tmp_disks; + } catch (OMVModuleZFSException $e) { + //Do nothing if an excpetion is thrown } } @@ -581,12 +585,16 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract { $disks = preg_split("/[,;]/", $params['devices']); //Use /dev/disk/by-path as suggested in ZoL FAQ. if ($params['diskpath']) { - if (file_exists("/dev/disk/by-path/")) { - $tmp_disks = array(); - foreach ($disks as $disk) { - $tmp_disks[] = OMVModuleZFSUtil::getDiskPath($disk); + try { + if (file_exists("/dev/disk/by-path/")) { + $tmp_disks = array(); + foreach ($disks as $disk) { + $tmp_disks[] = OMVModuleZFSUtil::getDiskPath($disk); + } + $disks = $tmp_disks; } - $disks = $tmp_disks; + } catch (OMVModuleZFSException $e) { + //Do nothing if an exception is thrown } } $vdev[] = new OMVModuleZFSVdev($params['name'], $pooltype, $disks);