fix(files_versions): only handle path updates when there is path

`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>
This commit is contained in:
Ferdinand Thiessen 2025-03-20 18:45:10 +01:00
parent 5862d5aea1
commit 8ca23f2c7d
No known key found for this signature in database
GPG key ID: 45FAE7268762B400

View file

@ -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 {