Esempio n. 1
0
 /**
  * @dataProvider dataTestUpdate
  *
  * @param string $path
  * @param boolean $isDir
  * @param array $allFiles
  * @param integer $numberOfFiles
  */
 public function testUpdate($path, $isDir, $allFiles, $numberOfFiles)
 {
     $this->encryptionManager->expects($this->once())->method('getEncryptionModule')->willReturn($this->encryptionModule);
     $this->view->expects($this->once())->method('is_dir')->willReturn($isDir);
     if ($isDir) {
         $this->util->expects($this->once())->method('getAllFiles')->willReturn($allFiles);
     }
     $this->fileHelper->expects($this->exactly($numberOfFiles))->method('getAccessList')->willReturn(['users' => [], 'public' => false]);
     $this->encryptionModule->expects($this->exactly($numberOfFiles))->method('update')->willReturn(true);
     $this->update->update($path);
 }
Esempio n. 2
0
	/**
	 * see http://php.net/manual/en/function.copy.php
	 *
	 * @param string $path1
	 * @param string $path2
	 * @return bool
	 */
	public function copy($path1, $path2) {

		$source = $this->getFullPath($path1);
		$target = $this->getFullPath($path2);

		if ($this->util->isExcluded($source)) {
			return $this->storage->copy($path1, $path2);
		}

		$result = $this->storage->copy($path1, $path2);

		if ($result && $this->encryptionManager->isEnabled()) {
			$keysCopied = $this->copyKeys($source, $target);

			if ($keysCopied &&
				dirname($source) !== dirname($target) &&
				$this->util->isFile($target)
			) {
				$this->update->update($target);
			}

			$data = $this->getMetaData($path1);

			if (isset($data['encrypted'])) {
				$this->getCache()->put($path2, ['encrypted' => $data['encrypted']]);
			}
			if (isset($data['size'])) {
				$this->updateUnencryptedSize($target, $data['size']);
			}
		}

		return $result;
	}