service/models/StoredContent.php
/**
     * Checks if given range of bytes is saved
     *
     * @param  integer  $start
     * @param  integer  $end
     * @return boolean
     */
Checks if given range of bytes is saved
@param  integer  $start
@param  integer  $end
@return boolean
Checks if given range of bytes is saved @param integer $start @param integer $end @return boolean
public function isRangeStored($start, $end)
    {
        $query = $this->getChunks();
        if ($start !== null && $end !== null) {
            $query->where(['and', ['<=', 'start', $start], ['>=', 'end', $start]]);
            $query->orWhere(['and', ['<=', 'start', $end], ['>=', 'end', $end]]);
            $query->orWhere(['and', ['>=', 'start', $start], ['<=', 'end', $end]]);
        }
        $query->orderBy(['start' => SORT_ASC, 'end' => SORT_DESC]);
        $chunks = $query->asArray(true)->all();
        if (empty($chunks)) {
            return false;
        }
        $rangeStart = $chunks[0]['start'];
        $rangeEnd = $chunks[0]['end'];
        if ($rangeStart > $start) {
            return false;
        }
        for ($i = 1; $i < count($chunks); $i++) {
            if ($chunks[$i]['start'] <= $rangeEnd + 1 && $rangeEnd + 1 <= $chunks[$i]['end']) {
                $rangeEnd = $chunks[$i]['end'];
            }
        }
        if ($rangeEnd < $end) {
            return false;
        }
        return true;
    }
public function isRangeStored ( $ start , $ end ) { $ query = $ this -> getChunks ( ) ; if ( $ start !== null && $ end !== null ) { $ query -> where ( [ 'and' , [ '<=' , 'start' , $ start ] , [ '>=' , 'end' , $ start ] ] ) ; $ query -> orWhere ( [ 'and' , [ '<=' , 'start' , $ end ] , [ '>=' , 'end' , $ end ] ] ) ; $ query -> orWhere ( [ 'and' , [ '>=' , 'start' , $ start ] , [ '<=' , 'end' , $ end ] ] ) ; } $ query -> orderBy ( [ 'start' => SORT_ASC , 'end' => SORT_DESC ] ) ; $ chunks = $ query -> asArray ( true ) -> all ( ) ; if ( empty ( $ chunks ) ) { return false ; } $ rangeStart = $ chunks [ 0 ] [ 'start' ] ; $ rangeEnd = $ chunks [ 0 ] [ 'end' ] ; if ( $ rangeStart > $ start ) { return false ; } for ( $ i = 1 ; $ i < count ( $ chunks ) ; $ i ++ ) { if ( $ chunks [ $ i ] [ 'start' ] <= $ rangeEnd + 1 && $ rangeEnd + 1 <= $ chunks [ $ i ] [ 'end' ] ) { $ rangeEnd = $ chunks [ $ i ] [ 'end' ] ; } } if ( $ rangeEnd < $ end ) { return false ; } return true ; }
Checks if given range of bytes is saved
 @param  integer  $start
 @param  integer  $end
 @return boolean
Checks if given range of bytes is saved @param integer $start @param integer $end @return boolean
//No start position found //No end position found