diff options
author | Lukas Reschke <lukas@owncloud.com> | 2016-06-21 11:18:22 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2016-06-21 11:18:22 +0200 |
commit | 2b493e2f9dca674ba11f88a1d182d6872e04eaaa (patch) | |
tree | ef7fa75d1b4da812de80e93c3590dbb5404d7f06 /apps/files_sharing/lib | |
parent | b4df57f3f02f65ed71d1072280751170379a53e8 (diff) | |
parent | 0e575c7eeadc6c8eb11b0be2ed1d39cdcf6cfcb8 (diff) | |
download | nextcloud-server-2b493e2f9dca674ba11f88a1d182d6872e04eaaa.tar.gz nextcloud-server-2b493e2f9dca674ba11f88a1d182d6872e04eaaa.zip |
Merge remote-tracking branch 'upstream/master' into master-sync-upstream
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r-- | apps/files_sharing/lib/AppInfo/Application.php | 3 | ||||
-rw-r--r-- | apps/files_sharing/lib/External/Storage.php | 11 | ||||
-rw-r--r-- | apps/files_sharing/lib/External/Watcher.php | 33 | ||||
-rw-r--r-- | apps/files_sharing/lib/Helper.php | 12 | ||||
-rw-r--r-- | apps/files_sharing/lib/MountProvider.php | 33 | ||||
-rw-r--r-- | apps/files_sharing/lib/SharedMount.php | 2 |
6 files changed, 77 insertions, 17 deletions
diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php index 2907ceaaea2..fda16c7acac 100644 --- a/apps/files_sharing/lib/AppInfo/Application.php +++ b/apps/files_sharing/lib/AppInfo/Application.php @@ -115,7 +115,8 @@ class Application extends App { $server = $c->query('ServerContainer'); return new MountProvider( $server->getConfig(), - $server->getShareManager() + $server->getShareManager(), + $server->getLogger() ); }); diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php index a12b9597dbd..ca99393a1e0 100644 --- a/apps/files_sharing/lib/External/Storage.php +++ b/apps/files_sharing/lib/External/Storage.php @@ -89,8 +89,17 @@ class Storage extends DAV implements ISharedStorage { 'user' => $options['token'], 'password' => (string)$options['password'] )); + } - $this->getWatcher()->setPolicy(\OC\Files\Cache\Watcher::CHECK_ONCE); + public function getWatcher($path = '', $storage = null) { + if (!$storage) { + $storage = $this; + } + if (!isset($this->watcher)) { + $this->watcher = new Watcher($storage); + $this->watcher->setPolicy(\OC\Files\Cache\Watcher::CHECK_ONCE); + } + return $this->watcher; } public function getRemoteUser() { diff --git a/apps/files_sharing/lib/External/Watcher.php b/apps/files_sharing/lib/External/Watcher.php new file mode 100644 index 00000000000..6be35bdeb3b --- /dev/null +++ b/apps/files_sharing/lib/External/Watcher.php @@ -0,0 +1,33 @@ +<?php +/** + * @author Robin Appelman <icewind@owncloud.com> + * + * @copyright Copyright (c) 2016, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ + +namespace OCA\Files_Sharing\External; + +class Watcher extends \OC\Files\Cache\Watcher { + /** + * remove deleted files in $path from the cache + * + * @param string $path + */ + public function cleanFolder($path) { + // not needed, the scanner takes care of this + } +} diff --git a/apps/files_sharing/lib/Helper.php b/apps/files_sharing/lib/Helper.php index e4640f82eb6..2353a281b7e 100644 --- a/apps/files_sharing/lib/Helper.php +++ b/apps/files_sharing/lib/Helper.php @@ -277,19 +277,23 @@ class Helper { /** * get default share folder * + * @param \OC\Files\View * @return string */ - public static function getShareFolder() { + public static function getShareFolder($view = null) { + if ($view === null) { + $view = Filesystem::getView(); + } $shareFolder = \OC::$server->getConfig()->getSystemValue('share_folder', '/'); $shareFolder = Filesystem::normalizePath($shareFolder); - if (!Filesystem::file_exists($shareFolder)) { + if (!$view->file_exists($shareFolder)) { $dir = ''; $subdirs = explode('/', $shareFolder); foreach ($subdirs as $subdir) { $dir = $dir . '/' . $subdir; - if (!Filesystem::is_dir($dir)) { - Filesystem::mkdir($dir); + if (!$view->is_dir($dir)) { + $view->mkdir($dir); } } } diff --git a/apps/files_sharing/lib/MountProvider.php b/apps/files_sharing/lib/MountProvider.php index d8f355f2fd3..a9ae48860c2 100644 --- a/apps/files_sharing/lib/MountProvider.php +++ b/apps/files_sharing/lib/MountProvider.php @@ -26,6 +26,7 @@ namespace OCA\Files_Sharing; use OCP\Files\Config\IMountProvider; use OCP\Files\Storage\IStorageFactory; use OCP\IConfig; +use OCP\ILogger; use OCP\IUser; use OCP\Share\IManager; @@ -41,12 +42,19 @@ class MountProvider implements IMountProvider { protected $shareManager; /** + * @var ILogger + */ + protected $logger; + + /** * @param \OCP\IConfig $config * @param IManager $shareManager + * @param ILogger $logger */ - public function __construct(IConfig $config, IManager $shareManager) { + public function __construct(IConfig $config, IManager $shareManager, ILogger $logger) { $this->config = $config; $this->shareManager = $shareManager; + $this->logger = $logger; } @@ -67,15 +75,20 @@ class MountProvider implements IMountProvider { $mounts = []; foreach ($shares as $share) { - $mounts[] = new SharedMount( - '\OC\Files\Storage\Shared', - $mounts, - [ - 'user' => $user->getUID(), - 'newShare' => $share, - ], - $storageFactory - ); + try { + $mounts[] = new SharedMount( + '\OC\Files\Storage\Shared', + $mounts, + [ + 'user' => $user->getUID(), + 'newShare' => $share, + ], + $storageFactory + ); + } catch (\Exception $e) { + $this->logger->logException($e); + $this->logger->error('Error while trying to create shared mount'); + } } // array_filter removes the null values from the array diff --git a/apps/files_sharing/lib/SharedMount.php b/apps/files_sharing/lib/SharedMount.php index 83527053f43..2b066bd2d94 100644 --- a/apps/files_sharing/lib/SharedMount.php +++ b/apps/files_sharing/lib/SharedMount.php @@ -81,7 +81,7 @@ class SharedMount extends MountPoint implements MoveableMount { $parent = dirname($share->getTarget()); if (!$this->recipientView->is_dir($parent)) { - $parent = Helper::getShareFolder(); + $parent = Helper::getShareFolder($this->recipientView); } $newMountPoint = $this->generateUniqueTarget( |