/** * @param int $id */ public function propagateById($id) { if (isset($this->propagatingIds[$id])) { return; } $this->propagatingIds[$id] = true; $shares = Share::getAllSharesForFileId($id); foreach ($shares as $share) { // propagate down the share tree $this->markDirty($share, microtime(true)); // propagate up the share tree if ($share['share_with'] === $this->userId) { $user = $share['uid_owner']; $view = new View('/' . $user . '/files'); try { $path = $view->getPath($share['file_source']); } catch (NotFoundException $e) { $path = null; } $watcher = new ChangeWatcher($view, $this->manager->getSharePropagator($user)); $watcher->writeHook(['path' => $path]); } } unset($this->propagatingIds[$id]); }
/** * Get all mountpoints applicable for the user and check for shares where we need to update the etags * * @param \OCP\IUser $user * @param \OCP\Files\Storage\IStorageFactory $storageFactory * @return \OCP\Files\Mount\IMountPoint[] */ public function getMountsForUser(IUser $user, IStorageFactory $storageFactory) { $shares = \OCP\Share::getItemsSharedWithUser('file', $user->getUID()); $propagator = $this->propagationManager->getSharePropagator($user->getUID()); $propagator->propagateDirtyMountPoints($shares); $shares = array_filter($shares, function ($share) { return $share['permissions'] > 0; }); $shares = array_map(function ($share) use($user, $storageFactory) { // for updating etags for the share owner when we make changes to this share. $ownerPropagator = $this->propagationManager->getChangePropagator($share['uid_owner']); return new SharedMount('\\OC\\Files\\Storage\\Shared', '/' . $user->getUID() . '/' . $share['file_target'], array('propagationManager' => $this->propagationManager, 'propagator' => $ownerPropagator, 'share' => $share, 'user' => $user->getUID()), $storageFactory); }, $shares); // array_filter removes the null values from the array return array_filter($shares); }
/** * Get all mountpoints applicable for the user and check for shares where we need to update the etags * * @param \OCP\IUser $user * @param \OCP\Files\Storage\IStorageFactory $storageFactory * @return \OCP\Files\Mount\IMountPoint[] */ public function getMountsForUser(IUser $user, IStorageFactory $storageFactory) { $shares = \OCP\Share::getItemsSharedWithUser('file', $user->getUID()); $propagator = $this->propagationManager->getSharePropagator($user->getUID()); $propagator->propagateDirtyMountPoints($shares); $shares = array_filter($shares, function ($share) { return $share['permissions'] > 0; }); return array_map(function ($share) use($user, $storageFactory) { Filesystem::initMountPoints($share['uid_owner']); // for updating etags for the share owner when we make changes to this share. $ownerPropagator = $this->propagationManager->getChangePropagator($share['uid_owner']); // for updating our etags when changes are made to the share from the owners side (probably indirectly by us trough another share) $this->propagationManager->listenToOwnerChanges($share['uid_owner'], $user->getUID()); return new SharedMount('\\OC\\Files\\Storage\\Shared', '/' . $user->getUID() . '/' . $share['file_target'], array('propagator' => $ownerPropagator, 'share' => $share, 'user' => $user->getUID()), $storageFactory); }, $shares); }
/** * Get all mountpoints applicable for the user and check for shares where we need to update the etags * * @param \OCP\IUser $user * @param \OCP\Files\Storage\IStorageFactory $storageFactory * @return \OCP\Files\Mount\IMountPoint[] */ public function getMountsForUser(IUser $user, IStorageFactory $storageFactory) { $shares = \OCP\Share::getItemsSharedWithUser('file', $user->getUID()); $propagator = $this->propagationManager->getSharePropagator($user->getUID()); $propagator->propagateDirtyMountPoints($shares); $shares = array_filter($shares, function ($share) { return $share['permissions'] > 0; }); $shares = array_map(function ($share) use($user, $storageFactory) { try { Filesystem::initMountPoints($share['uid_owner']); } catch (NoUserException $e) { \OC::$server->getLogger()->warning('The user \'' . $share['uid_owner'] . '\' of share with ID \'' . $share['id'] . '\' can\'t be retrieved.', array('app' => 'files_sharing')); return null; } // for updating etags for the share owner when we make changes to this share. $ownerPropagator = $this->propagationManager->getChangePropagator($share['uid_owner']); // for updating our etags when changes are made to the share from the owners side (probably indirectly by us trough another share) $this->propagationManager->listenToOwnerChanges($share['uid_owner'], $user->getUID()); return new SharedMount('\\OC\\Files\\Storage\\Shared', '/' . $user->getUID() . '/' . $share['file_target'], array('propagator' => $ownerPropagator, 'share' => $share, 'user' => $user->getUID()), $storageFactory); }, $shares); // array_filter removes the null values from the array return array_filter($shares); }
public function propagateById($id) { $shares = Share::getAllSharesForFileId($id); foreach ($shares as $share) { // propagate down the share tree $this->markDirty($share, microtime(true)); // propagate up the share tree if ($share['share_with'] === $this->userId) { $user = $share['uid_owner']; $view = new View('/' . $user . '/files'); $path = $view->getPath($share['file_source']); $watcher = new ChangeWatcher($view, $this->manager->getSharePropagator($user)); $watcher->writeHook(['path' => $path]); } } }