2727 */
2828class Files extends Action {
2929
30- private array | null $ renameParams = null ;
30+ private array $ renamedNodes = [] ;
3131 /**
3232 * Logs file read actions
3333 *
@@ -60,17 +60,13 @@ public function read(BeforeNodeReadEvent $event): void {
6060 public function beforeRename (BeforeNodeRenamedEvent $ event ): void {
6161 try {
6262 $ source = $ event ->getSource ();
63- $ params = [
64- 'oldid ' => $ source ->getId (),
65- 'oldpath ' => mb_substr ($ source ->getInternalPath (), 5 ),
66- ];
63+ $ this ->renamedNodes [$ source ->getId ()] = $ source ;
6764 } catch (InvalidPathException |NotFoundException $ e ) {
6865 \OCP \Server::get (LoggerInterface::class)->error (
6966 "Exception thrown in file rename: " .$ e ->getMessage (), ['app ' => 'admin_audit ' , 'exception ' => $ e ]
7067 );
7168 return ;
7269 }
73- $ this ->renameParams = $ params ;
7470 }
7571
7672 /**
@@ -81,10 +77,10 @@ public function beforeRename(BeforeNodeRenamedEvent $event): void {
8177 public function afterRename (NodeRenamedEvent $ event ): void {
8278 try {
8379 $ target = $ event ->getTarget ();
84- $ renameParams = $ this ->renameParams ;
80+ $ originalSource = $ this ->renamedNodes [ $ target -> getId ()] ;
8581 $ params = [
8682 'newid ' => $ target ->getId (),
87- 'oldpath ' => $ renameParams [ ' oldpath ' ] ,
83+ 'oldpath ' => mb_substr ( $ originalSource -> getInternalPath (), 5 ) ,
8884 'newpath ' => mb_substr ($ target ->getInternalPath (), 5 ),
8985 ];
9086 } catch (InvalidPathException |NotFoundException $ e ) {
0 commit comments