diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2025-03-20 18:45:10 +0100 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2025-04-27 23:51:56 +0200 |
commit | 8ca23f2c7d00dfb88307518650d3fee11c7de8d1 (patch) | |
tree | 7f9424d95602911e3dcfe291f8a84c20afd4cadb /apps | |
parent | 5862d5aea146b8f2a88e1c7110869dec1d1e9f3a (diff) | |
download | nextcloud-server-8ca23f2c7d00dfb88307518650d3fee11c7de8d1.tar.gz nextcloud-server-8ca23f2c7d00dfb88307518650d3fee11c7de8d1.zip |
fix(files_versions): only handle path updates when there is pathfix/files-versions-listeners
`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>
Diffstat (limited to 'apps')
-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 c581c61b4ae..d847c60ec64 100644 --- a/apps/files_versions/lib/Listener/FileEventsListener.php +++ b/apps/files_versions/lib/Listener/FileEventsListener.php @@ -332,11 +332,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); @@ -344,7 +352,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 { |