diff --git a/Build/phpstan/phpstan-baseline.neon b/Build/phpstan/phpstan-baseline.neon
index 4c3ec8b310de37acc5615384ca5e66d59b111754..d896d4cbb8797a895565981b3a9537b16d715139 100644
--- a/Build/phpstan/phpstan-baseline.neon
+++ b/Build/phpstan/phpstan-baseline.neon
@@ -805,11 +805,6 @@ parameters:
 			count: 2
 			path: ../../typo3/sysext/core/Classes/Resource/ResourceStorage.php
 
-		-
-			message: "#^Parameter \\#1 \\$fileObject of method TYPO3\\\\CMS\\\\Core\\\\Resource\\\\Index\\\\Indexer\\:\\:updateIndexEntry\\(\\) expects TYPO3\\\\CMS\\\\Core\\\\Resource\\\\File, TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FileInterface given\\.$#"
-			count: 2
-			path: ../../typo3/sysext/core/Classes/Resource/ResourceStorage.php
-
 		-
 			message: "#^Parameter \\#2 \\$folder of method TYPO3\\\\CMS\\\\Core\\\\Resource\\\\ResourceStorage\\:\\:checkFolderActionPermission\\(\\) expects TYPO3\\\\CMS\\\\Core\\\\Resource\\\\Folder\\|null, TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FolderInterface given\\.$#"
 			count: 1
diff --git a/typo3/sysext/core/Classes/Resource/ResourceStorage.php b/typo3/sysext/core/Classes/Resource/ResourceStorage.php
index f08f5b62c6d23765361250ef820c4420b0b3204c..70d1719c53779ef5c50087d2ac0d3a2a3574c44c 100644
--- a/typo3/sysext/core/Classes/Resource/ResourceStorage.php
+++ b/typo3/sysext/core/Classes/Resource/ResourceStorage.php
@@ -1991,7 +1991,9 @@ class ResourceStorage implements ResourceStorageInterface
                     $file->updateProperties(['storage' => $this->getUid(), 'identifier' => $newIdentifier]);
                 }
             }
-            $this->getIndexer()->updateIndexEntry($file);
+            if ($file instanceof File) {
+                $this->getIndexer()->updateIndexEntry($file);
+            }
         } catch (\TYPO3\CMS\Core\Exception $e) {
             echo $e->getMessage();
         }
@@ -2029,8 +2031,8 @@ class ResourceStorage implements ResourceStorageInterface
             $newIdentifier = $this->driver->renameFile($file->getIdentifier(), $sanitizedTargetFileName);
             if ($file instanceof File) {
                 $file->updateProperties(['identifier' => $newIdentifier]);
+                $this->getIndexer()->updateIndexEntry($file);
             }
-            $this->getIndexer()->updateIndexEntry($file);
         } catch (ExistingTargetFileNameException $exception) {
             if ($conflictMode->equals(DuplicationBehavior::RENAME)) {
                 $newName = $this->getUniqueName($file->getParentFolder(), $sanitizedTargetFileName);