Ejemplo n.º 1
0
 public function __construct(\OC\Files\Storage\Storage $storage)
 {
     $this->storage = $storage;
     $this->storageId = $this->storage->getId();
     $this->cache = $storage->getCache();
     $this->cacheActive = !Config::getSystemValue('filesystem_cache_readonly', false);
 }
Ejemplo n.º 2
0
 public function __construct(\OC\Files\Storage\Storage $storage)
 {
     $this->storage = $storage;
     $this->storageId = $this->storage->getId();
     $this->cache = $storage->getCache();
     $this->permissionsCache = $storage->getPermissionsCache();
 }
Ejemplo n.º 3
0
 /**
  * @param \OC\Files\Storage\Storage|string $storage
  * @throws \RuntimeException
  */
 public function __construct($storage)
 {
     if ($storage instanceof \OC\Files\Storage\Storage) {
         $this->storageId = $storage->getId();
     } else {
         $this->storageId = $storage;
     }
     $this->storageId = self::adjustStorageId($this->storageId);
     $sql = 'SELECT `numeric_id` FROM `*PREFIX*storages` WHERE `id` = ?';
     $result = \OC_DB::executeAudited($sql, array($this->storageId));
     if ($row = $result->fetchRow()) {
         $this->numericId = $row['numeric_id'];
     } else {
         $connection = \OC_DB::getConnection();
         if ($connection->insertIfNotExist('*PREFIX*storages', ['id' => $this->storageId])) {
             $this->numericId = \OC_DB::insertid('*PREFIX*storages');
         } else {
             $result = \OC_DB::executeAudited($sql, array($this->storageId));
             if ($row = $result->fetchRow()) {
                 $this->numericId = $row['numeric_id'];
             } else {
                 throw new \RuntimeException('Storage could neither be inserted nor be selected from the database');
             }
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * @param \OC\Files\Storage\Storage|string $storage
  */
 public function __construct($storage)
 {
     if ($storage instanceof \OC\Files\Storage\Storage) {
         $this->storageId = $storage->getId();
     } else {
         $this->storageId = $storage;
     }
 }
Ejemplo n.º 5
0
 /**
  * @param \OC\Files\Storage\Storage|string $storage
  */
 public function __construct($storage)
 {
     if ($storage instanceof \OC\Files\Storage\Storage) {
         $this->storageId = $storage->getId();
     } else {
         $this->storageId = $storage;
     }
     if (strlen($this->storageId) > 64) {
         $this->storageId = md5($this->storageId);
     }
     $this->storageCache = new Storage($storage);
 }
Ejemplo n.º 6
0
 /**
  * @param \OC\Files\Storage\Storage|string $storage
  */
 public function __construct($storage)
 {
     if ($storage instanceof \OC\Files\Storage\Storage) {
         $this->storageId = $storage->getId();
     } else {
         $this->storageId = $storage;
     }
     if (strlen($this->storageId) > 64) {
         $this->storageId = md5($this->storageId);
     }
     $this->storageCache = new Storage($storage);
     $this->mimetypeLoader = \OC::$server->getMimeTypeLoader();
 }
Ejemplo n.º 7
0
	/**
	 * @return string
	 */
	public function getStorageId() {
		if (!$this->storageId) {
			if (is_null($this->storage)) {
				$storage = $this->createStorage(); //FIXME: start using exceptions
				if (is_null($storage)) {
					return null;
				}

				$this->storage = $storage;
			}
			$this->storageId = $this->storage->getId();
			if (strlen($this->storageId) > 64) {
				$this->storageId = md5($this->storageId);
			}
		}
		return $this->storageId;
	}
Ejemplo n.º 8
0
 /**
  * @param \OC\Files\Storage\Storage|string $storage
  */
 public function __construct($storage)
 {
     if ($storage instanceof \OC\Files\Storage\Storage) {
         $this->storageId = $storage->getId();
     } else {
         $this->storageId = $storage;
     }
     $this->storageId = self::adjustStorageId($this->storageId);
     $sql = 'SELECT `numeric_id` FROM `*PREFIX*storages` WHERE `id` = ?';
     $result = \OC_DB::executeAudited($sql, array($this->storageId));
     if ($row = $result->fetchRow()) {
         $this->numericId = $row['numeric_id'];
     } else {
         $sql = 'INSERT INTO `*PREFIX*storages` (`id`) VALUES(?)';
         \OC_DB::executeAudited($sql, array($this->storageId));
         $this->numericId = \OC_DB::insertid('*PREFIX*storages');
     }
 }
Ejemplo n.º 9
0
 /**
  * @param \OC\Files\Storage\Storage|string $storage
  */
 public function __construct($storage)
 {
     if ($storage instanceof \OC\Files\Storage\Storage) {
         $this->storageId = $storage->getId();
     } else {
         $this->storageId = $storage;
     }
     if (strlen($this->storageId) > 64) {
         $this->storageId = md5($this->storageId);
     }
     $query = \OC_DB::prepare('SELECT `numeric_id` FROM `*PREFIX*storages` WHERE `id` = ?');
     $result = $query->execute(array($this->storageId));
     if ($row = $result->fetchRow()) {
         $this->numericId = $row['numeric_id'];
     } else {
         $query = \OC_DB::prepare('INSERT INTO `*PREFIX*storages`(`id`) VALUES(?)');
         $query->execute(array($this->storageId));
         $this->numericId = \OC_DB::insertid('*PREFIX*storages');
     }
 }
Ejemplo n.º 10
0
 /**
  * @param \OC\Files\Storage\Storage|string $storage
  * @param bool $isAvailable
  * @throws \RuntimeException
  */
 public function __construct($storage, $isAvailable = true)
 {
     if ($storage instanceof \OC\Files\Storage\Storage) {
         $this->storageId = $storage->getId();
     } else {
         $this->storageId = $storage;
     }
     $this->storageId = self::adjustStorageId($this->storageId);
     if ($row = self::getStorageById($this->storageId)) {
         $this->numericId = $row['numeric_id'];
     } else {
         $connection = \OC_DB::getConnection();
         if ($connection->insertIfNotExist('*PREFIX*storages', ['id' => $this->storageId, 'available' => $isAvailable])) {
             $this->numericId = \OC_DB::insertid('*PREFIX*storages');
         } else {
             if ($row = self::getStorageById($this->storageId)) {
                 $this->numericId = $row['numeric_id'];
             } else {
                 throw new \RuntimeException('Storage could neither be inserted nor be selected from the database');
             }
         }
     }
 }
Ejemplo n.º 11
0
 /**
  * Get the identifier for the storage,
  * the returned id should be the same for every storage object that is created with the same parameters
  * and two storage objects with the same id should refer to two storages that display the same files.
  *
  * @return string
  */
 public function getId()
 {
     return $this->storage->getId();
 }
Ejemplo n.º 12
0
 /**
  * get the numeric storage id
  *
  * @param \OC\Files\Storage\Storage $storage
  * @return int
  */
 function getNumericId($storage)
 {
     $storageId = $storage->getId();
     if (!isset($this->numericIds[$storageId])) {
         $cache = $storage->getCache();
         $this->numericIds[$storageId] = $cache->getNumericStorageId();
     }
     return $this->numericIds[$storageId];
 }