Skip to content

Commit

Permalink
Use getInternalPath instead of replacement regex
Browse files Browse the repository at this point in the history
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Nov 28, 2023
1 parent 0edd0b3 commit 07281be
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/Listeners/NodeRenamedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,13 @@ public function handle(Event $event): void {
if (($target instanceof Folder) &&
$sourceStorage->instanceOfStorage(GroupFolderStorage::class) &&
$targetStorage->instanceOfStorage(GroupFolderStorage::class)) {
$sourcePath = preg_replace('/^'.preg_quote($source->getParent()->getMountPoint()->getMountPoint(), '/').'/', '', $source->getPath());
$targetPath = preg_replace('/^'.preg_quote($target->getMountPoint()->getMountPoint(), '/').'/', '', $target->getPath());
// Get internal path on parent to avoid NotFoundException
$sourcePath = $source->getParent()->getInternalPath();
if ($sourcePath !== '') {
$sourcePath .= '/';
}
$sourcePath .= $source->getName();
$targetPath = $target->getInternalPath();
$this->trashManager->updateTrashedChildren($sourceStorage->getFolderId(), $targetStorage->getFolderId(), $sourcePath, $targetPath);
}
}
Expand Down

0 comments on commit 07281be

Please sign in to comment.