diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2025-03-20 18:45:10 +0100 |
---|---|---|
committer | Andy Scherzinger <info@andy-scherzinger.de> | 2025-06-17 20:00:33 +0200 |
commit | 6481ccbe37f085ec15afd123b64f191ba05b743f (patch) | |
tree | 88d4d952e40e5517211e022936afd038e3962713 | |
parent | 0f40e373f1dac435f37c0e124add1b6a37b4cd51 (diff) | |
download | nextcloud-server-backport/51609/stable30.tar.gz nextcloud-server-backport/51609/stable30.zip |
fix(files_versions): only handle path updates when there is pathbackport/51609/stable30
`getPathForNode` can fail with null for various reasons (e.g. no owner),
in this cases we need to just skip the event handling.
Co-authored-by: Ferdinand Thiessen <opensource@fthiessen.de>
Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
-rw-r--r-- | apps/files_versions/lib/Listener/FileEventsListener.php | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/apps/files_versions/lib/Listener/FileEventsListener.php b/apps/files_versions/lib/Listener/FileEventsListener.php index 633277cb458..6a2e82002de 100644 --- a/apps/files_versions/lib/Listener/FileEventsListener.php +++ b/apps/files_versions/lib/Listener/FileEventsListener.php @@ -374,11 +374,19 @@ class FileEventsListener implements IEventListener { return; } - // if we rename a movable mount point, then the versions don't have - // to be renamed + // if we rename a movable mount point, then the versions don't have to be renamed $oldPath = $this->getPathForNode($source); $newPath = $this->getPathForNode($target); - $absOldPath = Filesystem::normalizePath('/' . \OC_User::getUser() . '/files' . $oldPath); + if ($oldPath === null || $newPath === null) { + return; + } + + $user = $this->userSession->getUser()?->getUID(); + if ($user === null) { + return; + } + + $absOldPath = Filesystem::normalizePath('/' . $user . '/files' . $oldPath); $manager = Filesystem::getMountManager(); $mount = $manager->find($absOldPath); $internalPath = $mount->getInternalPath($absOldPath); @@ -386,7 +394,7 @@ class FileEventsListener implements IEventListener { return; } - $view = new View(\OC_User::getUser() . '/files'); + $view = new View($user . '/files'); if ($view->file_exists($newPath)) { Storage::store($newPath); } else { |