Skip to content

Commit abcbed7

Browse files
authored
Merge pull request #53518 from nextcloud/backport/51609/stable31
[stable31] fix(files_versions): only handle path updates when there is path
2 parents b6f8bbb + 9c20e30 commit abcbed7

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
@@ -332,19 +332,27 @@ public function pre_renameOrCopy_hook(Node $source, Node $target): void {
332332
return;
333333
}
334334

335-
// if we rename a movable mount point, then the versions don't have
336-
// to be renamed
335+
// if we rename a movable mount point, then the versions don't have to be renamed
337336
$oldPath = $this->getPathForNode($source);
338337
$newPath = $this->getPathForNode($target);
339-
$absOldPath = Filesystem::normalizePath('/' . \OC_User::getUser() . '/files' . $oldPath);
338+
if ($oldPath === null || $newPath === null) {
339+
return;
340+
}
341+
342+
$user = $this->userSession->getUser()?->getUID();
343+
if ($user === null) {
344+
return;
345+
}
346+
347+
$absOldPath = Filesystem::normalizePath('/' . $user . '/files' . $oldPath);
340348
$manager = Filesystem::getMountManager();
341349
$mount = $manager->find($absOldPath);
342350
$internalPath = $mount->getInternalPath($absOldPath);
343351
if ($internalPath === '' and $mount instanceof MoveableMount) {
344352
return;
345353
}
346354

347-
$view = new View(\OC_User::getUser() . '/files');
355+
$view = new View($user . '/files');
348356
if ($view->file_exists($newPath)) {
349357
Storage::store($newPath);
350358
} else {

0 commit comments

Comments
 (0)