]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/stacker/file/class_BaseFileStack.php
Continued:
[core.git] / framework / main / classes / stacker / file / class_BaseFileStack.php
index faa1b0dc513f7b3463fef1a69c8988be2afba879..1960259d04732e4c089505674822aca946646acc 100644 (file)
@@ -609,7 +609,8 @@ abstract class BaseFileStack extends BaseStacker {
         * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
         */
        public function searchNextGap (int $length) {
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: length=%s', $length));
+               // Not supported here
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: length=%d - CALLED!', $length));
                throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
        }
 
@@ -647,7 +648,14 @@ abstract class BaseFileStack extends BaseStacker {
                $gapPosition = $this->getIteratorInstance()->searchNextGap(strlen($rawData));
 
                // Gap position cannot be smaller than header length + 1
-               assert($gapPosition > $this->getIteratorInstance()->getHeaderSize());
+               if ($gapPosition <= $this->getIteratorInstance()->getHeaderSize()) {
+                       // Improper gap position
+                       throw new UnexpectedValueException(sprintf('gapPosition[%s]=%d is not larger than headerSize=%d',
+                               gettype($gapPosition),
+                               $gapPosition,
+                               $this->getIteratorInstance()->getHeaderSize()
+                       ));
+               }
 
                // Then write the data at that gap
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: groupId=%s,hash=%s,gapPosition=%s', $groupId, $hash, $gapPosition));