Skip to content

Commit 18bbd08

Browse files
Merge pull request #53519 from nextcloud/backport/51609/stable30
[stable30] fix(files_versions): only handle path updates when there is path
2 parents 5d54031 + 6481ccb commit 18bbd08

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

apps/files_versions/lib/Listener/FileEventsListener.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,19 +374,27 @@ public function pre_renameOrCopy_hook(Node $source, Node $target): void {
374374
return;
375375
}
376376

377-
// if we rename a movable mount point, then the versions don't have
378-
// to be renamed
377+
// if we rename a movable mount point, then the versions don't have to be renamed
379378
$oldPath = $this->getPathForNode($source);
380379
$newPath = $this->getPathForNode($target);
381-
$absOldPath = Filesystem::normalizePath('/' . \OC_User::getUser() . '/files' . $oldPath);
380+
if ($oldPath === null || $newPath === null) {
381+
return;
382+
}
383+
384+
$user = $this->userSession->getUser()?->getUID();
385+
if ($user === null) {
386+
return;
387+
}
388+
389+
$absOldPath = Filesystem::normalizePath('/' . $user . '/files' . $oldPath);
382390
$manager = Filesystem::getMountManager();
383391
$mount = $manager->find($absOldPath);
384392
$internalPath = $mount->getInternalPath($absOldPath);
385393
if ($internalPath === '' and $mount instanceof MoveableMount) {
386394
return;
387395
}
388396

389-
$view = new View(\OC_User::getUser() . '/files');
397+
$view = new View($user . '/files');
390398
if ($view->file_exists($newPath)) {
391399
Storage::store($newPath);
392400
} else {

0 commit comments

Comments
 (0)