Beispiel #1
0
 /**
  * Processes the Files which have been detected as "changed or new"
  * in the storage
  *
  * @return void
  */
 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);
             $fileObject = NULL;
             if (!empty($files)) {
                 foreach ($files as $fileIndexEntry) {
                     // 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));
                         $this->updateIndexEntry($fileObject);
                         $this->identifiedFileUids[] = $fileObject->getUid();
                         break;
                     }
                 }
             }
             // create new index when no missing file with same content hash is found
             if ($fileObject === NULL) {
                 $fileObject = $this->createIndexEntry($identifier);
                 $this->identifiedFileUids[] = $fileObject->getUid();
             }
         } else {
             // update existing file
             $fileObject = $this->getResourceFactory()->getFileObject($data['uid'], $data);
             $this->updateIndexEntry($fileObject);
         }
     }
 }
 /**
  * Checks if this file exists. This should normally always return TRUE;
  * it might only return FALSE when this object has been created from an
  * index record without checking for.
  *
  * @return boolean TRUE if this file physically exists
  */
 public function exists()
 {
     if ($this->deleted) {
         return FALSE;
     }
     return $this->storage->hasFile($this->getIdentifier());
 }
Beispiel #3
0
 /**
  * Since by now all files in filesystem have been looked at it is save to assume,
  * that files that are in indexed but not touched in this run are missing
  */
 protected function detectMissingFiles()
 {
     $indexedNotExistentFiles = $this->getFileIndexRepository()->findInStorageAndNotInUidList($this->storage, $this->identifiedFileUids);
     foreach ($indexedNotExistentFiles as $record) {
         if (!$this->storage->hasFile($record['identifier'])) {
             $this->getFileIndexRepository()->markFileAsMissing($record['uid']);
         }
     }
 }
 /**
  * @param ResourceStorage $storage
  * @param string $identifier
  *
  * @return null|ProcessedFile
  */
 public function findByStorageAndIdentifier(ResourceStorage $storage, $identifier)
 {
     $processedFileObject = null;
     if ($storage->hasFile($identifier)) {
         $databaseRow = $this->databaseConnection->exec_SELECTgetSingleRow('*', $this->table, 'storage = ' . (int) $storage->getUid() . ' AND identifier = ' . $this->databaseConnection->fullQuoteStr($identifier, $this->table));
         if ($databaseRow) {
             $processedFileObject = $this->createDomainObject($databaseRow);
         }
     }
     return $processedFileObject;
 }
Beispiel #5
0
 /**
  * @param ResourceStorage $storage
  * @param string $identifier
  *
  * @return null|ProcessedFile
  */
 public function findByStorageAndIdentifier(ResourceStorage $storage, $identifier)
 {
     $processedFileObject = null;
     if ($storage->hasFile($identifier)) {
         $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->table);
         $databaseRow = $queryBuilder->select('*')->from($this->table)->where($queryBuilder->expr()->eq('storage', $queryBuilder->createNamedParameter($storage->getUid(), \PDO::PARAM_INT)), $queryBuilder->expr()->eq('identifier', $queryBuilder->createNamedParameter($identifier, \PDO::PARAM_STR)))->execute()->fetch();
         if ($databaseRow) {
             $processedFileObject = $this->createDomainObject($databaseRow);
         }
     }
     return $processedFileObject;
 }