- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->readFileHeader() ...');
- $this->readFileHeader();
-
- // Not created/already exists?
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: created=%d', intval($created)));
- if (!$created) {
- // Count all entries in file
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->iteratorInstance->analyzeFile() ...');
- $this->getIteratorInstance()->analyzeFile();
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Invoking this->readStackHeader() ...');
+ $this->readStackHeader();
+
+ // Is the index loaded correctly, e.g. the stack file is just created?
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Invoking this->indexInstance->isIndexLoaded() ...');
+ if (!$this->getIndexInstance()->isIndexLoaded()) {
+ /*
+ * Something horrible has happened to the index as it should be
+ * loaded at this point. The stack's file structure then needs to
+ * be analyzed and the index rebuild.
+ */
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Invoking this->iteratorInstance->analyzeFileStructure() ...');
+ $this->getIteratorInstance()->getBinaryFileInstance()->analyzeFileStructure();
+
+ // Rebuild index from file
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: Invoking this->iteratorInstance->rebuildIndexFromStack(%s) ...', $this->__toString()));
+ $this->getIndexInstance()->rebuildIndexFromStack($this);