diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-11-09 12:36:35 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2016-12-22 10:48:32 +0100 |
commit | 34d466b2f6184a1bfd886e09a45056c76bc83ee6 (patch) | |
tree | cf18c8da8890de9b54c3564ad6699de7f64bc053 /apps/files_trashbin/lib | |
parent | 8f664a00e1e37d8a38ffe0ad2c33c3b64a1ba59c (diff) | |
download | nextcloud-server-34d466b2f6184a1bfd886e09a45056c76bc83ee6.tar.gz nextcloud-server-34d466b2f6184a1bfd886e09a45056c76bc83ee6.zip |
Fallback to share link owner when no owner found
When creating link shares from external storage, the filesystem cannot
find an owner in some scenarios (ex: system-wide mounts). In such
cases, fall back to using the current user's trashbin which happens to
also be the user who created the link share.
Fixes an issue where this scenario made deletion impossible due to
missing user information.
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'apps/files_trashbin/lib')
-rw-r--r-- | apps/files_trashbin/lib/Trashbin.php | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index bf2fa57453f..f8067949cda 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -88,6 +88,10 @@ class Trashbin { if (!$userManager->userExists($uid)) { $uid = User::getUser(); } + if (!$uid) { + // no owner, usually because of share link from ext storage + return [null, null]; + } Filesystem::initMountPoints($uid); if ($uid != User::getUser()) { $info = Filesystem::getFileInfo($filename); @@ -204,6 +208,12 @@ class Trashbin { list(, $user) = explode('/', $root); list($owner, $ownerPath) = self::getUidAndFilename($file_path); + // if no owner found (ex: ext storage + share link), will use the current user's trashbin then + if (is_null($owner)) { + $owner = $user; + $ownerPath = $file_path; + } + $ownerView = new View('/' . $owner); // file has been deleted in between if (is_null($ownerPath) || $ownerPath === '' || !$ownerView->file_exists('/files/' . $ownerPath)) { |