Commit 0b91f8d9 authored by Vincent Petry's avatar Vincent Petry Committed by Thomas Müller
Browse files

Fallback to share link owner when no owner found (#26587)

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.
parent 728fd5e2
...@@ -87,6 +87,10 @@ class Trashbin { ...@@ -87,6 +87,10 @@ class Trashbin {
if (!$userManager->userExists($uid)) { if (!$userManager->userExists($uid)) {
$uid = User::getUser(); $uid = User::getUser();
} }
if (!$uid) {
// no owner, usually because of share link from ext storage
return [null, null];
}
Filesystem::initMountPoints($uid); Filesystem::initMountPoints($uid);
if ($uid != User::getUser()) { if ($uid != User::getUser()) {
$info = Filesystem::getFileInfo($filename); $info = Filesystem::getFileInfo($filename);
...@@ -203,6 +207,12 @@ class Trashbin { ...@@ -203,6 +207,12 @@ class Trashbin {
list(, $user) = explode('/', $root); list(, $user) = explode('/', $root);
list($owner, $ownerPath) = self::getUidAndFilename($file_path); 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); $ownerView = new View('/' . $owner);
// file has been deleted in between // file has been deleted in between
if (is_null($ownerPath) || $ownerPath === '' || !$ownerView->file_exists('/files/' . $ownerPath)) { if (is_null($ownerPath) || $ownerPath === '' || !$ownerView->file_exists('/files/' . $ownerPath)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment