From 141eaab9c4babb883f75fae3b96519dd6a4362a2 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 17 Sep 2020 16:19:41 +0200 Subject: 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/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 977e642948c..3a08dda1cf9 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(); @@ -155,7 +156,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!', @@ -163,12 +165,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 { @@ -190,14 +194,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 46c97db94b9..294dd7e2a96 100644 --- a/apps/files/lib/Helper.php +++ b/apps/files/lib/Helper.php @@ -63,6 +63,7 @@ class Helper { 'owner' => $storageInfo['owner'], 'ownerDisplayName' => $storageInfo['ownerDisplayName'], 'mountType' => $storageInfo['mountType'], + 'mountPoint' => $storageInfo['mountPoint'], ]; } diff --git a/lib/private/legacy/helper.php b/lib/private/legacy/helper.php index 0f7b2d1b3af..387999a96da 100644 --- a/lib/private/legacy/helper.php +++ b/lib/private/legacy/helper.php @@ -544,6 +544,7 @@ class OC_Helper { if($owner) { $ownerDisplayName = $owner->getDisplayName(); } + [,,,$mountPoint] = explode('/', $mount->getMountPoint(), 4); return [ 'free' => $free, @@ -553,7 +554,8 @@ class OC_Helper { 'relative' => $relative, 'owner' => $ownerId, 'ownerDisplayName' => $ownerDisplayName, - 'mountType' => $mount->getMountType() + 'mountType' => $mount->getMountType(), + 'mountPoint' => trim($mountPoint, '/'), ]; } -- cgit v1.2.3 From 16554001839b08f9b68e869495953fbb6f27950d Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 5 Oct 2020 15:49:00 +0200 Subject: 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 641b03e0781..890c3392cd0 100644 --- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php @@ -299,6 +299,9 @@ class DirectoryTest extends \Test\TestCase { ->method('getMountPoint') ->willReturn($mountPoint); + $mountPoint->method('getMountPoint') + ->willReturn('/user/files/mymountpoint'); + $dir = new Directory($this->view, $this->info); $this->assertEquals([200, -3], $dir->getQuotaInfo()); //200 used, unlimited } @@ -334,6 +337,9 @@ class DirectoryTest extends \Test\TestCase { ->method('getMountPoint') ->willReturn($mountPoint); + $mountPoint->method('getMountPoint') + ->willReturn('/user/files/mymountpoint'); + $dir = new Directory($this->view, $this->info); $this->assertEquals([200, 800], $dir->getQuotaInfo()); //200 used, 800 free } -- cgit v1.2.3 From e29eb55f8b709c420689571964dae8e36b18fa37 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 21 Oct 2020 13:37:56 +0200 Subject: Only use index of mount point when it is there Signed-off-by: Joas Schilling --- lib/private/legacy/helper.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/private/legacy/helper.php b/lib/private/legacy/helper.php index 387999a96da..ae933421bce 100644 --- a/lib/private/legacy/helper.php +++ b/lib/private/legacy/helper.php @@ -544,7 +544,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, -- cgit v1.2.3