@@ -43,7 +43,7 @@ class FilesHooks {
4343
4444 /** @var string|bool */
4545 protected $ moveCase = false ;
46- /** @var array */
46+ /** @var array|null */
4747 protected $ oldAccessList ;
4848 /** @var string */
4949 protected $ oldParentPath ;
@@ -275,22 +275,30 @@ public function fileMove($oldPath, $newPath) {
275275 $ this ->moveCase = 'moveCross ' ;
276276 }
277277
278- [$ this ->oldParentPath , $ this ->oldParentOwner , $ this ->oldParentId ] = $ this ->getSourcePathAndOwner ($ oldDir );
279- if ($ this ->oldParentId === 0 ) {
280- // Could not find the file for the owner ...
281- $ this ->moveCase = false ;
282- return ;
283- }
278+ try {
279+ [$ this ->oldParentPath , $ this ->oldParentOwner , $ this ->oldParentId ] = $ this ->getSourcePathAndOwner ($ oldDir );
280+ if ($ this ->oldParentId === 0 ) {
281+ // Could not find the file for the owner ...
282+ $ this ->moveCase = false ;
283+ return ;
284+ }
284285
285- $ oldAccessList = $ this ->getUserPathsFromPath ($ this ->oldParentPath , $ this ->oldParentOwner );
286+ $ oldAccessList = $ this ->getUserPathsFromPath ($ this ->oldParentPath , $ this ->oldParentOwner );
286287
287- // file can be shared using GroupFolders, including ACL check
288- if ($ this ->config ->getSystemValueBool ('activity_use_cached_mountpoints ' , false )) {
289- [, , $ oldFileId ] = $ this ->getSourcePathAndOwner ($ oldPath );
290- $ oldAccessList ['users ' ] = array_merge ($ oldAccessList ['users ' ], $ this ->getAffectedUsersFromCachedMounts ($ oldFileId ));
291- }
288+ // file can be shared using GroupFolders, including ACL check
289+ if ($ this ->config ->getSystemValueBool ('activity_use_cached_mountpoints ' , false )) {
290+ [, , $ oldFileId ] = $ this ->getSourcePathAndOwner ($ oldPath );
291+ $ oldAccessList ['users ' ] = array_merge ($ oldAccessList ['users ' ], $ this ->getAffectedUsersFromCachedMounts ($ oldFileId ));
292+ }
292293
293- $ this ->oldAccessList = $ oldAccessList ;
294+ $ this ->oldAccessList = $ oldAccessList ;
295+ } catch (NotFoundException $ e ) {
296+ // The old location cannot be resolved (e.g. inconsistent mount or file
297+ // cache state), so fileMovePost() would have no valid data to build
298+ // activities from. Skip it instead of failing the move half-way.
299+ $ this ->logger ->warning ('Could not resolve the old location of " ' . $ oldPath . '", no move activities will be created ' , ['exception ' => $ e ]);
300+ $ this ->moveCase = false ;
301+ }
294302 }
295303
296304
@@ -392,6 +400,12 @@ protected function fileRenaming($oldPath, $newPath) {
392400 * @param string $newPath
393401 */
394402 protected function fileMoving ($ oldPath , $ newPath ) {
403+ if (!is_array ($ this ->oldAccessList )) {
404+ // fileMove() could not collect the old access list, so there is no
405+ // base to compute the activities from
406+ return ;
407+ }
408+
395409 $ dirName = dirname ($ newPath );
396410 $ fileName = basename ($ newPath );
397411 $ oldFileName = basename ($ oldPath );
0 commit comments