From 64bbd21e870071117dea02e2d30c5d5db42a52bb Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Wed, 21 Aug 2024 11:17:40 +0200 Subject: [PATCH] fix: allow dot in mounted on Signed-off-by: Daniel Kesselberg --- lib/OperatingSystems/Linux.php | 2 +- tests/data/linux_df_tp | 1 + tests/lib/LinuxTest.php | 10 +++++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/OperatingSystems/Linux.php b/lib/OperatingSystems/Linux.php index 46d367c4..b8711709 100644 --- a/lib/OperatingSystems/Linux.php +++ b/lib/OperatingSystems/Linux.php @@ -216,7 +216,7 @@ public function getDiskInfo(): array { } $matches = []; - $pattern = '/^(?[\S]+)\s*(?[\S]+)\s*(?\d+)\s*(?\d+)\s*(?\d+)\s*(?\d+%)\s*(?[\w\/-]+)$/m'; + $pattern = '/^(?[\S]+)\s*(?[\S]+)\s*(?\d+)\s*(?\d+)\s*(?\d+)\s*(?\d+%)\s*(?[\w\/\-\.]+)$/m'; $result = preg_match_all($pattern, $disks, $matches); if ($result === 0 || $result === false) { diff --git a/tests/data/linux_df_tp b/tests/data/linux_df_tp index c330e565..e277e53b 100644 --- a/tests/data/linux_df_tp +++ b/tests/data/linux_df_tp @@ -11,3 +11,4 @@ home_vagrant_code vboxsf 958123168 614831132 343292036 tmpfs tmpfs 816800 0 816800 0% /run/user/1000 nfs.example.com:/export nfs4 14820 0 1230 0% /nfs 198.51.100.42:/storage fuse.sshfs 47929956 53116 45419052 1% /mnt/sshfs +/dev/vda5 ext4 205314024 110088996 84722884 57% /nextcloud/my.cloud.domain.xx diff --git a/tests/lib/LinuxTest.php b/tests/lib/LinuxTest.php index 7c5d431d..0f181ebb 100644 --- a/tests/lib/LinuxTest.php +++ b/tests/lib/LinuxTest.php @@ -205,7 +205,15 @@ public function testGetDiskInfo(): void { $disk6->setPercent('1%'); $disk6->setMount('/mnt/sshfs'); - $this->assertEquals([$disk1, $disk2, $disk3, $disk4, $disk5, $disk6], $this->os->getDiskInfo()); + $disk7 = new Disk(); + $disk7->setDevice('/dev/vda5'); + $disk7->setFs('ext4'); + $disk7->setUsed(107508); + $disk7->setAvailable(82737); + $disk7->setPercent('57%'); + $disk7->setMount('/nextcloud/my.cloud.domain.xx'); + + $this->assertEquals([$disk1, $disk2, $disk3, $disk4, $disk5, $disk6, $disk7], $this->os->getDiskInfo()); } public function testGetDiskInfoNoCommandOutput(): void {