/**
  * propagate the registered changes to their parent folders
  *
  * @param int $time (optional) the mtime to set for the folders, if not set the current time is used
  */
 public function propagateChanges($time = null)
 {
     $changes = $this->getChanges();
     $this->changedFiles = [];
     if (!$time) {
         $time = time();
     }
     foreach ($changes as $change) {
         /**
          * @var \OC\Files\Storage\Storage $storage
          * @var string $internalPath
          */
         $absolutePath = $this->view->getAbsolutePath($change);
         $mount = $this->view->getMount($change);
         $storage = $mount->getStorage();
         $internalPath = $mount->getInternalPath($absolutePath);
         if ($storage) {
             $propagator = $storage->getPropagator();
             $propagatedEntries = $propagator->propagateChange($internalPath, $time);
             foreach ($propagatedEntries as $entry) {
                 $absolutePath = Filesystem::normalizePath($mount->getMountPoint() . '/' . $entry['path']);
                 $relativePath = $this->view->getRelativePath($absolutePath);
                 $this->emit('\\OC\\Files', 'propagate', [$relativePath, $entry]);
             }
         }
     }
 }
Example #2
0
 static function folder($params)
 {
     $internalPath = $params['path'];
     $mountPoint = self::$mountPoints[$params['storage']];
     $path = self::$view->getRelativePath($mountPoint . $internalPath);
     self::$eventSource->send('folder', $path);
 }
Example #3
0
 /**
  * Sets up the node, expects a full path name
  *
  * @param \OC\Files\View $view
  * @param \OCP\Files\FileInfo $info
  * @param IManager $shareManager
  */
 public function __construct($view, $info, IManager $shareManager = null)
 {
     $this->fileView = $view;
     $this->path = $this->fileView->getRelativePath($info->getPath());
     $this->info = $info;
     if ($shareManager) {
         $this->shareManager = $shareManager;
     } else {
         $this->shareManager = \OC::$server->getShareManager();
     }
 }
Example #4
0
 /**
  * Find all files and their encryption status within a directory
  * @param string $directory The path of the parent directory to search
  * @param bool $found the founded files if called again
  * @return array keys: plain, encrypted, broken
  * @note $directory needs to be a path relative to OC data dir. e.g.
  *       /admin/files NOT /backup OR /home/www/oc/data/admin/files
  */
 public function findEncFiles($directory, &$found = false)
 {
     // Disable proxy - we don't want files to be decrypted before
     // we handle them
     \OC_FileProxy::$enabled = false;
     if ($found === false) {
         $found = array('plain' => array(), 'encrypted' => array(), 'broken' => array());
     }
     if ($this->view->is_dir($directory) && ($handle = $this->view->opendir($directory))) {
         if (is_resource($handle)) {
             while (false !== ($file = readdir($handle))) {
                 if ($file !== "." && $file !== "..") {
                     // skip stray part files
                     if (Helper::isPartialFilePath($file)) {
                         continue;
                     }
                     $filePath = $directory . '/' . $this->view->getRelativePath('/' . $file);
                     $relPath = Helper::stripUserFilesPath($filePath);
                     // If the path is a directory, search
                     // its contents
                     if ($this->view->is_dir($filePath)) {
                         $this->findEncFiles($filePath, $found);
                         // If the path is a file, determine
                         // its encryption status
                     } elseif ($this->view->is_file($filePath)) {
                         // Disable proxies again, some-
                         // where they got re-enabled :/
                         \OC_FileProxy::$enabled = false;
                         $isEncryptedPath = $this->isEncryptedPath($filePath);
                         // If the file is encrypted
                         // NOTE: If the userId is
                         // empty or not set, file will
                         // detected as plain
                         // NOTE: This is inefficient;
                         // scanning every file like this
                         // will eat server resources :(
                         if ($isEncryptedPath) {
                             $fileKey = Keymanager::getFileKey($this->view, $this, $relPath);
                             $shareKey = Keymanager::getShareKey($this->view, $this->userId, $this, $relPath);
                             // if file is encrypted but now file key is available, throw exception
                             if ($fileKey === false || $shareKey === false) {
                                 \OCP\Util::writeLog('encryption library', 'No keys available to decrypt the file: ' . $filePath, \OCP\Util::ERROR);
                                 $found['broken'][] = array('name' => $file, 'path' => $filePath);
                             } else {
                                 $found['encrypted'][] = array('name' => $file, 'path' => $filePath);
                             }
                             // If the file is not encrypted
                         } else {
                             $found['plain'][] = array('name' => $file, 'path' => $relPath);
                         }
                     }
                 }
             }
         }
     }
     \OC_FileProxy::$enabled = true;
     return $found;
 }
Example #5
0
File: node.php Project: evanjt/core
 /**
  * Sets up the node, expects a full path name
  *
  * @param \OC\Files\View $view
  * @param \OCP\Files\FileInfo $info
  */
 public function __construct($view, $info)
 {
     $this->fileView = $view;
     $this->path = $this->fileView->getRelativePath($info->getPath());
     $this->info = $info;
 }
Example #6
0
	protected function getPropagatorPath($path) {
		return $this->propagatorView->getRelativePath($this->view->getAbsolutePath($path));
	}