Beispiel #1
0
 /**
  * Constructor
  * Creates directory for locks if needed
  */
 public function __construct()
 {
     if (!\Includes\Utils\FileManager::isExists(rtrim(static::LOCK_DIR, LC_DS))) {
         \Includes\Utils\FileManager::mkdirRecursive(rtrim(static::LOCK_DIR, LC_DS));
     }
     if (!\Includes\Utils\FileManager::isReadable(static::LOCK_DIR) || !\Includes\Utils\FileManager::isWriteable(static::LOCK_DIR)) {
         \XLite\Logger::getInstance()->log('Cannot create lock for keys', LOG_DEBUG);
     }
     parent::__construct();
 }
Beispiel #2
0
 /**
  * Verify value as file
  *
  * @param mixed @value Value
  *
  * @return boolean
  */
 protected function verifyValueAsFile($value)
 {
     // Do not verify files in verification mode and if 'ignoreFileChecking' option is true
     if (!$this->isVerification() || !$this->importer->getOptions()->ignoreFileChecking) {
         if (1 < count(parse_url($value))) {
             $request = new \XLite\Core\HTTP\Request($value);
             $response = $request->sendRequest();
             $result = $response && 200 == $response->code;
         } else {
             $dir = \Includes\Utils\FileManager::getRealPath(LC_DIR_VAR . $this->importer->getOptions()->dir);
             $result = \Includes\Utils\FileManager::isReadable($dir . LC_DS . $value);
         }
     } else {
         $result = true;
     }
     return $result;
 }
Beispiel #3
0
 /**
  * Set repository path
  *
  * @param string  $path            Path to set
  * @param boolean $preventCheck    Flag OPTIONAL
  * @param boolean $preventDeletion Flag OPTIONAL
  *
  * @return void
  */
 public function setRepositoryPath($path, $preventCheck = false, $preventDeletion = false)
 {
     if (!empty($path) && !$preventCheck) {
         $path = \Includes\Utils\FileManager::getRealPath($path);
         if (empty($path) || !\Includes\Utils\FileManager::isReadable($path)) {
             $path = null;
         }
     }
     if (!$preventDeletion && !empty($this->repositoryPath) && $path !== $this->repositoryPath) {
         if ($this->isDownloaded()) {
             \Includes\Utils\FileManager::deleteFile($this->repositoryPath);
         } elseif ($this->isUnpacked()) {
             \Includes\Utils\FileManager::deleteFile($this->getCurrentVersionHashesFilePath());
             \Includes\Utils\FileManager::unlinkRecursive($this->repositoryPath);
         }
     }
     $this->repositoryPath = $path;
 }