From f70abf493975b7b75c3111588f94616414ac3311 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 17 Sep 2020 16:19:41 +0200 Subject: [PATCH 1/3] add mount point to quota warning message makes it more clear to the user what the quota applies to Signed-off-by: Robin Appelman --- apps/files/js/files.js | 18 +++++++++++------- apps/files/lib/Helper.php | 1 + lib/private/legacy/OC_Helper.php | 4 +++- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/apps/files/js/files.js b/apps/files/js/files.js index cdc1c70ffc..2f570f450c 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -73,6 +73,7 @@ $('#upload.button').attr('data-original-title', response.data.maxHumanFilesize); $('#usedSpacePercent').val(response.data.usedSpacePercent); $('#usedSpacePercent').data('mount-type', response.data.mountType); + $('#usedSpacePercent').data('mount-point', response.data.mountPoint); $('#owner').val(response.data.owner); $('#ownerDisplayName').val(response.data.ownerDisplayName); Files.displayStorageWarnings(); @@ -157,7 +158,8 @@ var usedSpacePercent = $('#usedSpacePercent').val(), owner = $('#owner').val(), ownerDisplayName = $('#ownerDisplayName').val(), - mountType = $('#usedSpacePercent').data('mount-type'); + mountType = $('#usedSpacePercent').data('mount-type'), + mountPoint = $('#usedSpacePercent').data('mount-point'); if (usedSpacePercent > 98) { if (owner !== OC.getCurrentUser().uid) { OC.Notification.show(t('files', 'Storage of {owner} is full, files can not be updated or synced anymore!', @@ -165,12 +167,14 @@ ); } else if (mountType === 'group') { OC.Notification.show(t('files', - 'This group folder is full, files can not be updated or synced anymore!'), + 'Group folder "{mountPoint}" is full, files can not be updated or synced anymore!', + {mountPoint: mountPoint}), {type: 'error'} ); } else if (mountType === 'external') { OC.Notification.show(t('files', - 'This external storage is full, files can not be updated or synced anymore!'), + 'External storage "{mountPoint}" is full, files can not be updated or synced anymore!', + {mountPoint: mountPoint}), {type : 'error'} ); } else { @@ -192,14 +196,14 @@ ); } else if (mountType === 'group') { OC.Notification.show(t('files', - 'This group folder is almost full ({usedSpacePercent}%)', - {usedSpacePercent: usedSpacePercent}), + 'Group folder "{mountPoint}" is almost full ({usedSpacePercent}%)', + {mountPoint: mountPoint, usedSpacePercent: usedSpacePercent}), {type : 'error'} ); } else if (mountType === 'external') { OC.Notification.show(t('files', - 'This external storage is almost full ({usedSpacePercent}%)', - {usedSpacePercent: usedSpacePercent}), + 'External storage "{mountPoint}" is almost full ({usedSpacePercent}%)', + {mountPoint: mountPoint, usedSpacePercent: usedSpacePercent}), {type : 'error'} ); } else { diff --git a/apps/files/lib/Helper.php b/apps/files/lib/Helper.php index 1f728565ca..2d5a3e2f26 100644 --- a/apps/files/lib/Helper.php +++ b/apps/files/lib/Helper.php @@ -64,6 +64,7 @@ class Helper { 'owner' => $storageInfo['owner'], 'ownerDisplayName' => $storageInfo['ownerDisplayName'], 'mountType' => $storageInfo['mountType'], + 'mountPoint' => $storageInfo['mountPoint'], ]; } diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php index d9c0c16de0..f37ee2caac 100644 --- a/lib/private/legacy/OC_Helper.php +++ b/lib/private/legacy/OC_Helper.php @@ -545,6 +545,7 @@ class OC_Helper { if ($owner) { $ownerDisplayName = $owner->getDisplayName(); } + [,,,$mountPoint] = explode('/', $mount->getMountPoint(), 4); return [ 'free' => $free, @@ -554,7 +555,8 @@ class OC_Helper { 'relative' => $relative, 'owner' => $ownerId, 'ownerDisplayName' => $ownerDisplayName, - 'mountType' => $mount->getMountType() + 'mountType' => $mount->getMountType(), + 'mountPoint' => trim($mountPoint, '/'), ]; } From 565ae7d493bfd9baf6692e6988888d190f440988 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 5 Oct 2020 15:49:00 +0200 Subject: [PATCH 2/3] Fix unit tests Signed-off-by: Roeland Jago Douma --- apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php index db79ea21b0..2207f9e641 100644 --- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php @@ -303,6 +303,9 @@ class DirectoryTest extends \Test\TestCase { ->method('getFileInfo') ->willReturn($this->info); + $mountPoint->method('getMountPoint') + ->willReturn('/user/files/mymountpoint'); + $dir = new Directory($this->view, $this->info); $this->assertEquals([200, -3], $dir->getQuotaInfo()); //200 used, unlimited } @@ -338,6 +341,9 @@ class DirectoryTest extends \Test\TestCase { ->method('getMountPoint') ->willReturn($mountPoint); + $mountPoint->method('getMountPoint') + ->willReturn('/user/files/mymountpoint'); + $this->view->expects($this->once()) ->method('getFileInfo') ->willReturn($this->info); From b9db1cede3d40bf84d394d007827260f14015d8d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 21 Oct 2020 13:37:56 +0200 Subject: [PATCH 3/3] Only use index of mount point when it is there Signed-off-by: Joas Schilling --- lib/private/legacy/OC_Helper.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php index f37ee2caac..f7ef398ca4 100644 --- a/lib/private/legacy/OC_Helper.php +++ b/lib/private/legacy/OC_Helper.php @@ -545,7 +545,11 @@ class OC_Helper { if ($owner) { $ownerDisplayName = $owner->getDisplayName(); } - [,,,$mountPoint] = explode('/', $mount->getMountPoint(), 4); + if (substr_count($mount->getMountPoint(), '/') < 3) { + $mountPoint = ''; + } else { + [,,,$mountPoint] = explode('/', $mount->getMountPoint(), 4); + } return [ 'free' => $free,