Esempio n. 1
0
 /**
  * Correct the parent folders' ETags for all users shared the file at $target
  *
  * @param string $target
  */
 public static function correctFolders($target)
 {
     $uid = \OCP\User::getUser();
     $uidOwner = \OC\Files\Filesystem::getOwner($target);
     $info = \OC\Files\Filesystem::getFileInfo($target);
     // Correct Shared folders of other users shared with
     $users = \OCP\Share::getUsersItemShared('file', $info['fileid'], $uidOwner, true);
     if (!empty($users)) {
         while (!empty($users)) {
             $reshareUsers = array();
             foreach ($users as $user) {
                 if ($user !== $uidOwner) {
                     $etag = \OC\Files\Filesystem::getETag('');
                     \OCP\Config::setUserValue($user, 'files_sharing', 'etag', $etag);
                     // Look for reshares
                     $reshareUsers = array_merge($reshareUsers, \OCP\Share::getUsersItemShared('file', $info['fileid'], $user, true));
                 }
             }
             $users = $reshareUsers;
         }
         // Correct folders of shared file owner
         $target = substr($target, 8);
         if ($uidOwner !== $uid && ($source = \OC_Share_Backend_File::getSource($target))) {
             \OC\Files\Filesystem::initMountPoints($uidOwner);
             $source = '/' . $uidOwner . '/' . $source['path'];
             \OC\Files\Cache\Updater::correctFolder($source, $info['mtime']);
         }
     }
 }
Esempio n. 2
0
	/**
	 * Get the source file path, permissions, and owner for a shared file
	 * @param string $target Shared target file path
	 * @return Returns array with the keys path, permissions, and owner or false if not found
	 */
	public function getFile($target) {
		if (!isset($this->files[$target])) {
			// Check for partial files
			if (pathinfo($target, PATHINFO_EXTENSION) === 'part') {
				$source = \OC_Share_Backend_File::getSource(substr($target, 0, -5), $this->getMountPoint(), $this->getItemType());
				if ($source) {
					$source['path'] .= '.part';
					// All partial files have delete permission
					$source['permissions'] |= \OCP\Constants::PERMISSION_DELETE;
				}
			} else {
				$source = \OC_Share_Backend_File::getSource($target, $this->getMountPoint(), $this->getItemType());
			}
			$this->files[$target] = $source;
		}
		return $this->files[$target];
	}
Esempio n. 3
0
 /**
  * Move a file or folder in the cache
  *
  * @param string $source
  * @param string $target
  */
 public function move($source, $target)
 {
     if ($cache = $this->getSourceCache($source)) {
         $file = \OC_Share_Backend_File::getSource($target, $this->storage->getMountPoint(), $this->storage->getItemType());
         if ($file && isset($file['path'])) {
             $cache->move($this->files[$source], $file['path']);
         }
     }
 }
Esempio n. 4
0
 /**
  * Get the storage id and path needed for a move
  *
  * @param string $path
  * @return array [$storageId, $internalPath]
  */
 protected function getMoveInfo($path)
 {
     $cache = $this->getSourceCache($path);
     $file = \OC_Share_Backend_File::getSource($path, $this->storage->getShare());
     return [$cache->getNumericStorageId(), $file['path']];
 }
Esempio n. 5
0
 /**
  * Move a file or folder in the cache
  *
  * @param string $source
  * @param string $target
  */
 public function move($source, $target)
 {
     if ($cache = $this->getSourceCache($source)) {
         $file = \OC_Share_Backend_File::getSource($target);
         if ($file && isset($file['path'])) {
             $cache->move($this->files[$source], $file['path']);
         }
     }
 }