[BUGFIX] Make sure all new files are indexed 69/32269/2
authorFrans Saris <franssaris@gmail.com>
Tue, 5 Aug 2014 14:19:19 +0000 (16:19 +0200)
committerMarkus Klein <klein.t3@reelworx.at>
Wed, 20 Aug 2014 11:02:55 +0000 (13:02 +0200)
If the FAL indexer scheduler task finds a index record with
same content hash as a new found file the file isn't added to the
index if it isn't marked as missing.

This patch changes the indexer so that new files with same
content hash are added when no index record is found for a missing
file with same content hash.

Resolves: #60764
Releases: 6.3, 6.2
Change-Id: Ifb7f9e6f48ba327c958a7aa0e0b71f0575cabdf7
Reviewed-on: http://review.typo3.org/32269
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/core/Classes/Resource/Index/Indexer.php

index 43528fb..2898c66 100644 (file)
@@ -172,11 +172,14 @@ class Indexer {
        protected function processChangedAndNewFiles() {
                foreach ($this->filesToUpdate AS $identifier => $data) {
                        if ($data == NULL) {
+                               // search for files with same content hash in indexed storage
                                $fileHash = $this->storage->hashFileByIdentifier($identifier, 'sha1');
                                $files = $this->getFileIndexRepository()->findByContentHash($fileHash);
-                               if (count($files) > 0) {
+                               $fileObject = NULL;
+                               if (!empty($files)) {
                                        foreach ($files as $fileIndexEntry) {
-                                               if ($fileIndexEntry['missing']) {
+                                               // check if file is missing then we assume it's moved/renamed
+                                               if (!$this->storage->hasFile($fileIndexEntry['identifier'])) {
                                                        $fileObject = $this->getResourceFactory()->getFileObject($fileIndexEntry['uid'], $fileIndexEntry);
                                                        $fileObject->updateProperties(array(
                                                                'identifier' => $identifier
@@ -186,8 +189,9 @@ class Indexer {
                                                        break;
                                                }
                                        }
-                               } else {
-                                       // index new file
+                               }
+                               // create new index when no missing file with same content hash is found
+                               if ($fileObject === NULL) {
                                        $fileObject = $this->createIndexEntry($identifier);
                                        $this->identifiedFileUids[] = $fileObject->getUid();
                                }