Exemplo n.º 1
1
 protected function _exec($sql)
 {
     if (!$this->_db->exec($this->_sql($sql))) {
         // TODO send error message to out
         $this->_out->stop("Sqlite exec error");
     }
 }
Exemplo n.º 2
0
 public function init($myrole, $drivers)
 {
     $this->_out->logNotice(">>>init " . get_class($this) . " driver as {$myrole}");
     $this->_asRemote = $myrole == Core_Engine::ROLE_REMOTE;
     $this->_drivers = $drivers;
     if (false === $this->_baseDir) {
         $this->_out->stop("parameter 'baseDir' is required by driver '{$this->_identity}'");
     }
     if (!file_exists($this->_baseDir)) {
         $this->_out->stop("local folder {$this->_baseDir} doesn't exists");
     }
     return true;
 }
Exemplo n.º 3
0
 /**
  * lists bucket's objects, applying callback to each of them
  *
  * @param mixed $callback first argument of the callback is CFSimpleXML object
  * @param array $params
  */
 protected function _list($callback, $params = array())
 {
     // prepare data for loop
     $bucket = $this->getBucket();
     $baseDir = $this->getBaseDir();
     $marker = '';
     $itemCount = 0;
     $v = false;
     $firstBatch = true;
     do {
         $list = $this->_s3->list_objects($bucket, array('marker' => $marker, 'prefix' => $baseDir));
         if (!is_object($list->body->Contents)) {
             $this->_out->stop("S3 response problem, no content returned");
         }
         $count = $list->body->Contents->count();
         if ($count === 0) {
             if ($firstBatch) {
                 break;
             } else {
                 $this->_out->stop("S3 response problem, not all files returned");
             }
         }
         $this->_itemCount += $count;
         $jobFiles = $this->_out->jobStart("processing information about {$count} remote files");
         // download meta data
         //            $batch = new CFBatchRequest(3);
         //            foreach ($list->body->Contents as $v) {
         //                /** @noinspection PhpUndefinedMethodInspection */
         //                $this->_s3->batch($batch)->get_object_headers($bucket, $v->Key); // Get content-type
         //        }
         //            /** @var $response CFArray */
         //            $response = $this->_s3->batch($batch)->send();
         //            if (!$response->areOK()) {
         //                $this->_out->stop("S3 response problem, meta data not returned");
         //            }
         //            if (count($response) != $count) {
         //                $this->_out->stop("S3 response problem, meta data not returned for all files");
         //            }
         // process received information
         $metaId = 0;
         foreach ($list->body->Contents as $v) {
             switch (true) {
                 case is_array($callback):
                 case is_string($callback):
                     call_user_func($callback, $v, $params);
                     break;
                 case is_callable($callback):
                     /** @var $callback Closure */
                     $callback($v, $params);
                     break;
             }
         }
         $this->_out->jobEnd($jobFiles, "updated info about one batch of files");
         // move to next batch of files
         $marker = $v->Key;
         $firstBatch = false;
     } while ((string) $list->body->IsTruncated == 'true');
 }