Exemple #1
0
 /**
  * Create a new database.
  *
  * @param boolean $quoted
  *   Quote the database name. Mysql uses backticks to quote which can cause problems
  *   in a Windows shell. Set TRUE if the CREATE is not running on the bash command line.
  */
 public function createdb($quoted = FALSE)
 {
     // Make sure sqlite can create file
     $file = $this->db_spec['database'];
     $path = dirname($file);
     drush_log("SQLITE: creating '{$path}' for creating '{$file}'", 'debug');
     drush_mkdir($path);
     if (!file_exists($path)) {
         drush_log("SQLITE: Cannot create {$path}", 'error');
     }
 }
Exemple #2
0
 /**
  * Create a new database.
  *
  * @param boolean $quoted
  *   Quote the database name. Mysql uses backticks to quote which can cause problems
  *   in a Windows shell. Set TRUE if the CREATE is not running on the bash command line.
  */
 public function createdb($quoted = FALSE)
 {
     $file = $this->db_spec['database'];
     if (file_exists($file)) {
         drush_log("SQLITE: Deleting existing database '{$file}'", LogLevel::DEBUG);
         drush_delete_dir($file, TRUE);
     }
     // Make sure sqlite can create file
     $path = dirname($file);
     drush_log("SQLITE: creating '{$path}' for creating '{$file}'", LogLevel::DEBUG);
     drush_mkdir($path);
     if (!file_exists($path)) {
         drush_log("SQLITE: Cannot create {$path}", LogLevel::ERROR);
     }
 }
Exemple #3
0
 function set($cid, $data, $expire = DRUSH_CACHE_PERMANENT, array $headers = NULL)
 {
     $created = time();
     $cache = new \stdClass();
     $cache->cid = $cid;
     $cache->data = is_object($data) ? clone $data : $data;
     $cache->created = $created;
     $cache->headers = $headers;
     if ($expire == DRUSH_CACHE_TEMPORARY) {
         $cache->expire = $created + 2591999;
     } elseif ($expire != DRUSH_CACHE_PERMANENT && $expire < 2592000) {
         $cache->expire = $created + $expire;
     } else {
         $cache->expire = $expire;
     }
     // Ensure the cache directory still exists, in case a backend process
     // cleared the cache after the cache was initialized.
     drush_mkdir($this->directory);
     $filename = $this->getFilePath($cid);
     return $this->writeFile($filename, $cache);
 }
 /**
  * Download and prepare a version of drush.
  *
  * @param int $version
  *   The major drush version to install.
  *
  * @return bool
  */
 public function install($version)
 {
     // Check for valid versions.
     if (!($drush = $this->validateVersion($version))) {
         return FALSE;
     }
     // Make sure the directory exists.
     $path = "{$this->dir}/{$drush['subdir']}";
     if (!drush_mkdir($path, TRUE)) {
         return FALSE;
     }
     // If it's not empty, skip this installation.
     if ($this->dirIsEmpty($drush['subdir'])) {
         if ($composer = $this->getComposer()) {
             return drush_shell_exec("{$composer} -d={$path} require drush/drush {$drush['composer_version']}");
         } else {
             // @todo: Provide alternative download methods.
             // https://github.com/KeyboardCowboy/drush-multidrush/issues/1
         }
     } else {
         return drush_log(dt("Drush {$version} is already installed.  Skipping."), 'status');
     }
 }