Beispiel #1
0
 private function clean()
 {
     $dirs = glob(APPLICATION_PATH . DS . 'storage' . DS . 'db' . DS . 'caching' . DS . 'expires' . DS . '*');
     foreach ($dirs as $dir) {
         $when = (int) Arrays::last(explode('/', $dir));
         if ($when < time()) {
             $files = glob($dir . DS . '*.db');
             if (!empty($files)) {
                 foreach ($files as $file) {
                     $key = str_replace('.db', '', Arrays::last(explode('/', $file)));
                     $fileToDelete = $this->getFile($key);
                     File::delete($fileToDelete);
                     File::delete($file);
                 }
             }
             File::rmdir($dir);
         }
     }
 }
Beispiel #2
0
 public function rollback()
 {
     $target = str_replace('copy.', '', $this->dir);
     File::rmdir($this->dir);
     $this->dir = $target;
 }
Beispiel #3
0
 public function dropTable()
 {
     File::rmdir($this->dir);
     return $this;
 }
Beispiel #4
0
 private function prepare()
 {
     $results = $collection = [];
     $hash = $this->db->getHash();
     $this->cursor = $this->db->motor()->getPath() . DS . 'cursors' . DS . $hash;
     if (is_dir($this->cursor)) {
         $ageCursor = filemtime($this->cursor . DS . '.');
         $ageDb = $this->db->getAge();
         if ($ageDb < $ageCursor) {
             $this->count = count(glob($this->cursor . DS . '*.php', GLOB_NOSORT));
             return;
         } else {
             File::rmdir($this->cursor);
         }
     }
     File::mkdir($this->db->motor()->getPath() . DS . 'cursors');
     File::mkdir($this->db->motor()->getPath() . DS . 'cursors' . DS . $hash);
     if (empty($this->db->wheres)) {
         $ids = $this->db->motor()->ids('datas');
         foreach ($ids as $id) {
             $results[$id] = [];
         }
         unset($ids);
     } else {
         $results = $this->db->results;
     }
     $this->count = count($results);
     if (empty($results)) {
         File::rmdir($this->cursor);
         return true;
     } else {
         $index = 0;
         foreach ($results as $id => $row) {
             if (false !== $id) {
                 $file = $this->cursor . DS . $index . '.php';
                 $data = $this->db->motor()->read('datas.' . $id);
                 File::put($file, "<?php\nreturn " . var_export($data, 1) . ';');
                 $index++;
             }
         }
     }
 }
Beispiel #5
0
 public function reclone($name = null)
 {
     $name = is_null($name) ? 'clone_' . $this->table : $name;
     File::rmdir(str_replace(DS . $name, DS . $this->table, $this->dir));
     File::cpdir($this->dir, str_replace(DS . $name, DS . $this->table, $this->dir));
     File::rmdir($this->dir);
     return $this;
 }
Beispiel #6
0
 /**
  * [drop description]
  *
  * @method drop
  *
  * @return [type] [description]
  */
 public function drop()
 {
     $dir = $this->store->getDir();
     File::rmdir($dir);
     return true;
 }
Beispiel #7
0
 public static function cleanCache($dir = null)
 {
     $dir = is_null($dir) ? Conf::get('dir.raw.store', STORAGE_PATH . DS . 'raw') : $dir;
     $dirs = glob($dir . DS . '*', GLOB_NOSORT);
     foreach ($dirs as $dir) {
         if (is_dir($dir)) {
             if (fnmatch('*/sessme.*', $dir) || fnmatch('*/me.*', $dir) || fnmatch('*/temporary.*', $dir)) {
                 $age = filemtime($dir);
                 $diff = time() - $age;
                 \Thin\Cli::show("{$diff}", 'INFO');
                 if ($diff > 3600 || fnmatch('*/temporary.*', $dir)) {
                     File::rmdir($dir);
                     \Thin\Cli::show("delete {$dir}", 'COMMENT');
                 }
             }
         }
     }
     $dir = Conf::get('dir.raw.models', APPLICATION_PATH . DS . 'models' . DS . 'Raw') . DS . 'models/temporary';
     File::rmdir($dir);
 }
Beispiel #8
0
 public function flush()
 {
     File::rmdir($this->dir);
     return $this;
 }
Beispiel #9
0
 public static function cleanCache($dir = null)
 {
     $dir = is_null($dir) ? STORAGE_PATH . DS . 'store' : $dir;
     $dirs = glob($dir . DS . '*', GLOB_NOSORT);
     foreach ($dirs as $dir) {
         if (is_dir($dir)) {
             if (fnmatch('*/sessme.*', $dir) || fnmatch('*/me.*', $dir) || fnmatch('*/temporary.*', $dir)) {
                 $age = filemtime($dir);
                 $diff = time() - $age;
                 Cli::show("{$diff}", 'INFO');
                 if ($diff > 3600 || fnmatch('*/temporary.*', $dir)) {
                     File::rmdir($dir);
                     Cli::show("delete {$dir}", 'COMMENT');
                 }
             }
         }
     }
 }