Ejemplo n.º 1
0
 /**
  * Wraps the given storage when it is not a shared storage
  *
  * @param string $mountPoint
  * @param Storage $storage
  * @param IMountPoint $mount
  * @return Encryption|Storage
  */
 public function wrapStorage($mountPoint, Storage $storage, IMountPoint $mount)
 {
     $parameters = ['storage' => $storage, 'mountPoint' => $mountPoint, 'mount' => $mount];
     if (!$storage->instanceOfStorage('OC\\Files\\Storage\\Shared') && !$storage->instanceOfStorage('OCA\\Files_Sharing\\External\\Storage') && !$storage->instanceOfStorage('OC\\Files\\Storage\\OwnCloud')) {
         $user = \OC::$server->getUserSession()->getUser();
         $mountManager = Filesystem::getMountManager();
         $uid = $user ? $user->getUID() : null;
         $fileHelper = \OC::$server->getEncryptionFilesHelper();
         $keyStorage = \OC::$server->getEncryptionKeyStorage();
         $util = new Util(new View(), \OC::$server->getUserManager(), \OC::$server->getGroupManager(), \OC::$server->getConfig());
         $update = new Update(new View(), $util, Filesystem::getMountManager(), $this->manager, $fileHelper, $uid);
         return new Encryption($parameters, $this->manager, $util, $this->logger, $fileHelper, $uid, $keyStorage, $update, $mountManager, $this->arrayCache);
     } else {
         return $storage;
     }
 }
Ejemplo n.º 2
0
	/**
	 * Returns whether a part file is needed for the given storage
	 * or whether the file can be assembled/uploaded directly on the
	 * target storage.
	 *
	 * @param \OCP\Files\Storage $storage
	 * @return bool true if the storage needs part file handling
	 */
	private function needsPartFile($storage) {
		// TODO: in the future use ChunkHandler provided by storage
		// and/or add method on Storage called "needsPartFile()"
		return !$storage->instanceOfStorage('OCA\Files_Sharing\External\Storage') &&
		!$storage->instanceOfStorage('OC\Files\Storage\OwnCloud');
	}
Ejemplo n.º 3
0
	/**
	 * @param \OCP\Files\Storage $sourceStorage
	 * @param string $sourceInternalPath
	 * @param string $targetInternalPath
	 * @return bool
	 */
	public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
		if ($sourceStorage->instanceOfStorage('\OC\Files\Storage\Local')) {
			/**
			 * @var \OC\Files\Storage\Local $sourceStorage
			 */
			$rootStorage = new Local(['datadir' => '/']);
			return $rootStorage->rename($sourceStorage->getSourcePath($sourceInternalPath), $this->getSourcePath($targetInternalPath));
		} else {
			return parent::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
		}
	}
Ejemplo n.º 4
0
	/**
	 * Wraps the given storage when it is not a shared storage
	 *
	 * @param string $mountPoint
	 * @param Storage $storage
	 * @param IMountPoint $mount
	 * @return Encryption|Storage
	 */
	public function wrapStorage($mountPoint, Storage $storage, IMountPoint $mount) {
		$parameters = [
			'storage' => $storage,
			'mountPoint' => $mountPoint,
			'mount' => $mount];

		if (!$storage->instanceOfStorage('OC\Files\Storage\Shared')
			&& !$storage->instanceOfStorage('OCA\Files_Sharing\External\Storage')
			&& !$storage->instanceOfStorage('OC\Files\Storage\OwnCloud')) {

			$manager = \OC::$server->getEncryptionManager();
			$user = \OC::$server->getUserSession()->getUser();
			$logger = \OC::$server->getLogger();
			$mountManager = Filesystem::getMountManager();
			$uid = $user ? $user->getUID() : null;
			$fileHelper = \OC::$server->getEncryptionFilesHelper();
			$keyStorage = \OC::$server->getEncryptionKeyStorage();
			$update = new Update(
				new View(),
				$this,
				Filesystem::getMountManager(),
				$manager,
				$fileHelper,
				$uid
			);
			return new Encryption(
				$parameters,
				$manager,
				$this,
				$logger,
				$fileHelper,
				$uid,
				$keyStorage,
				$update,
				$mountManager
			);
		} else {
			return $storage;
		}
	}