Beispiel #1
0
 /**
  * get the filesystem info
  *
  * @param string $path
  * @param boolean|string $includeMountPoints true to add mountpoint sizes,
  * 'ext' to add only ext storage mount point sizes. Defaults to true.
  * defaults to true
  * @return \OC\Files\FileInfo|false False if file does not exist
  */
 public function getFileInfo($path, $includeMountPoints = true)
 {
     $this->assertPathLength($path);
     if (!Filesystem::isValidPath($path)) {
         return false;
     }
     if (Cache\Scanner::isPartialFile($path)) {
         return $this->getPartFileInfo($path);
     }
     $relativePath = $path;
     $path = Filesystem::normalizePath($this->fakeRoot . '/' . $path);
     $mount = Filesystem::getMountManager()->find($path);
     $storage = $mount->getStorage();
     $internalPath = $mount->getInternalPath($path);
     if ($storage) {
         $data = $this->getCacheEntry($storage, $internalPath, $relativePath);
         if (!$data instanceof ICacheEntry) {
             return false;
         }
         if ($mount instanceof MoveableMount && $internalPath === '') {
             $data['permissions'] |= \OCP\Constants::PERMISSION_DELETE;
         }
         $owner = $this->getUserObjectForOwner($storage->getOwner($internalPath));
         $info = new FileInfo($path, $storage, $internalPath, $data, $mount, $owner);
         if ($data and isset($data['fileid'])) {
             if ($includeMountPoints and $data['mimetype'] === 'httpd/unix-directory') {
                 //add the sizes of other mount points to the folder
                 $extOnly = $includeMountPoints === 'ext';
                 $mounts = Filesystem::getMountManager()->findIn($path);
                 foreach ($mounts as $mount) {
                     $subStorage = $mount->getStorage();
                     if ($subStorage) {
                         // exclude shared storage ?
                         if ($extOnly && $subStorage instanceof \OC\Files\Storage\Shared) {
                             continue;
                         }
                         $subCache = $subStorage->getCache('');
                         $rootEntry = $subCache->get('');
                         $info->addSubEntry($rootEntry, $mount->getMountPoint());
                     }
                 }
             }
         }
         return $info;
     }
     return false;
 }