Completed
Pull Request — master (#3044)
by Thomas
15:53
created
apps/files_sharing/lib/External/MountProvider.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -29,59 +29,59 @@
 block discarded – undo
29 29
 use OCP\IUser;
30 30
 
31 31
 class MountProvider implements IMountProvider {
32
-	const STORAGE = '\OCA\Files_Sharing\External\Storage';
32
+    const STORAGE = '\OCA\Files_Sharing\External\Storage';
33 33
 
34
-	/**
35
-	 * @var \OCP\IDBConnection
36
-	 */
37
-	private $connection;
34
+    /**
35
+     * @var \OCP\IDBConnection
36
+     */
37
+    private $connection;
38 38
 
39
-	/**
40
-	 * @var callable
41
-	 */
42
-	private $managerProvider;
39
+    /**
40
+     * @var callable
41
+     */
42
+    private $managerProvider;
43 43
 
44
-	/**
45
-	 * @var ICloudIdManager
46
-	 */
47
-	private $cloudIdManager;
44
+    /**
45
+     * @var ICloudIdManager
46
+     */
47
+    private $cloudIdManager;
48 48
 
49
-	/**
50
-	 * @param \OCP\IDBConnection $connection
51
-	 * @param callable $managerProvider due to setup order we need a callable that return the manager instead of the manager itself
52
-	 * @param ICloudIdManager $cloudIdManager
53
-	 */
54
-	public function __construct(IDBConnection $connection, callable $managerProvider, ICloudIdManager $cloudIdManager) {
55
-		$this->connection = $connection;
56
-		$this->managerProvider = $managerProvider;
57
-		$this->cloudIdManager = $cloudIdManager;
58
-	}
49
+    /**
50
+     * @param \OCP\IDBConnection $connection
51
+     * @param callable $managerProvider due to setup order we need a callable that return the manager instead of the manager itself
52
+     * @param ICloudIdManager $cloudIdManager
53
+     */
54
+    public function __construct(IDBConnection $connection, callable $managerProvider, ICloudIdManager $cloudIdManager) {
55
+        $this->connection = $connection;
56
+        $this->managerProvider = $managerProvider;
57
+        $this->cloudIdManager = $cloudIdManager;
58
+    }
59 59
 
60
-	public function getMount(IUser $user, $data, IStorageFactory $storageFactory) {
61
-		$managerProvider = $this->managerProvider;
62
-		$manager = $managerProvider();
63
-		$data['manager'] = $manager;
64
-		$mountPoint = '/' . $user->getUID() . '/files/' . ltrim($data['mountpoint'], '/');
65
-		$data['mountpoint'] = $mountPoint;
66
-		$data['cloudId'] = $this->cloudIdManager->getCloudId($data['owner'], $data['remote']);
67
-		$data['certificateManager'] = \OC::$server->getCertificateManager($user->getUID());
68
-		$data['HttpClientService'] = \OC::$server->getHTTPClientService();
69
-		return new Mount(self::STORAGE, $mountPoint, $data, $manager, $storageFactory);
70
-	}
60
+    public function getMount(IUser $user, $data, IStorageFactory $storageFactory) {
61
+        $managerProvider = $this->managerProvider;
62
+        $manager = $managerProvider();
63
+        $data['manager'] = $manager;
64
+        $mountPoint = '/' . $user->getUID() . '/files/' . ltrim($data['mountpoint'], '/');
65
+        $data['mountpoint'] = $mountPoint;
66
+        $data['cloudId'] = $this->cloudIdManager->getCloudId($data['owner'], $data['remote']);
67
+        $data['certificateManager'] = \OC::$server->getCertificateManager($user->getUID());
68
+        $data['HttpClientService'] = \OC::$server->getHTTPClientService();
69
+        return new Mount(self::STORAGE, $mountPoint, $data, $manager, $storageFactory);
70
+    }
71 71
 
72
-	public function getMountsForUser(IUser $user, IStorageFactory $loader) {
73
-		$query = $this->connection->prepare('
72
+    public function getMountsForUser(IUser $user, IStorageFactory $loader) {
73
+        $query = $this->connection->prepare('
74 74
 				SELECT `remote`, `share_token`, `password`, `mountpoint`, `owner`
75 75
 				FROM `*PREFIX*share_external`
76 76
 				WHERE `user` = ? AND `accepted` = ?
77 77
 			');
78
-		$query->execute([$user->getUID(), 1]);
79
-		$mounts = [];
80
-		while ($row = $query->fetch()) {
81
-			$row['manager'] = $this;
82
-			$row['token'] = $row['share_token'];
83
-			$mounts[] = $this->getMount($user, $row, $loader);
84
-		}
85
-		return $mounts;
86
-	}
78
+        $query->execute([$user->getUID(), 1]);
79
+        $mounts = [];
80
+        while ($row = $query->fetch()) {
81
+            $row['manager'] = $this;
82
+            $row['token'] = $row['share_token'];
83
+            $mounts[] = $this->getMount($user, $row, $loader);
84
+        }
85
+        return $mounts;
86
+    }
87 87
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/External/Watcher.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -23,12 +23,12 @@
 block discarded – undo
23 23
 namespace OCA\Files_Sharing\External;
24 24
 
25 25
 class Watcher extends \OC\Files\Cache\Watcher {
26
-	/**
27
-	 * remove deleted files in $path from the cache
28
-	 *
29
-	 * @param string $path
30
-	 */
31
-	public function cleanFolder($path) {
32
-		// not needed, the scanner takes care of this
33
-	}
26
+    /**
27
+     * remove deleted files in $path from the cache
28
+     *
29
+     * @param string $path
30
+     */
31
+    public function cleanFolder($path) {
32
+        // not needed, the scanner takes care of this
33
+    }
34 34
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/External/Mount.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -29,43 +29,43 @@
 block discarded – undo
29 29
 
30 30
 class Mount extends MountPoint implements MoveableMount {
31 31
 
32
-	/**
33
-	 * @var \OCA\Files_Sharing\External\Manager
34
-	 */
35
-	protected $manager;
32
+    /**
33
+     * @var \OCA\Files_Sharing\External\Manager
34
+     */
35
+    protected $manager;
36 36
 
37
-	/**
38
-	 * @param string|\OC\Files\Storage\Storage $storage
39
-	 * @param string $mountpoint
40
-	 * @param array $options
41
-	 * @param \OCA\Files_Sharing\External\Manager $manager
42
-	 * @param \OC\Files\Storage\StorageFactory $loader
43
-	 */
44
-	public function __construct($storage, $mountpoint, $options, $manager, $loader = null) {
45
-		parent::__construct($storage, $mountpoint, $options, $loader);
46
-		$this->manager = $manager;
47
-	}
37
+    /**
38
+     * @param string|\OC\Files\Storage\Storage $storage
39
+     * @param string $mountpoint
40
+     * @param array $options
41
+     * @param \OCA\Files_Sharing\External\Manager $manager
42
+     * @param \OC\Files\Storage\StorageFactory $loader
43
+     */
44
+    public function __construct($storage, $mountpoint, $options, $manager, $loader = null) {
45
+        parent::__construct($storage, $mountpoint, $options, $loader);
46
+        $this->manager = $manager;
47
+    }
48 48
 
49
-	/**
50
-	 * Move the mount point to $target
51
-	 *
52
-	 * @param string $target the target mount point
53
-	 * @return bool
54
-	 */
55
-	public function moveMount($target) {
56
-		$result = $this->manager->setMountPoint($this->mountPoint, $target);
57
-		$this->setMountPoint($target);
49
+    /**
50
+     * Move the mount point to $target
51
+     *
52
+     * @param string $target the target mount point
53
+     * @return bool
54
+     */
55
+    public function moveMount($target) {
56
+        $result = $this->manager->setMountPoint($this->mountPoint, $target);
57
+        $this->setMountPoint($target);
58 58
 
59
-		return $result;
60
-	}
59
+        return $result;
60
+    }
61 61
 
62
-	/**
63
-	 * Remove the mount points
64
-	 *
65
-	 * @return mixed
66
-	 * @return bool
67
-	 */
68
-	public function removeMount() {
69
-		return $this->manager->removeShare($this->mountPoint);
70
-	}
62
+    /**
63
+     * Remove the mount points
64
+     *
65
+     * @return mixed
66
+     * @return bool
67
+     */
68
+    public function removeMount() {
69
+        return $this->manager->removeShare($this->mountPoint);
70
+    }
71 71
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/Updater.php 1 patch
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -27,81 +27,81 @@
 block discarded – undo
27 27
 
28 28
 class Updater {
29 29
 
30
-	/**
31
-	 * @param array $params
32
-	 */
33
-	static public function renameHook($params) {
34
-		self::renameChildren($params['oldpath'], $params['newpath']);
35
-		self::moveShareToShare($params['newpath']);
36
-	}
37
-
38
-	/**
39
-	 * Fix for https://github.com/owncloud/core/issues/20769
40
-	 *
41
-	 * The owner is allowed to move their files (if they are shared) into a receiving folder
42
-	 * In this case we need to update the parent of the moved share. Since they are
43
-	 * effectively handing over ownership of the file the rest of the code needs to know
44
-	 * they need to build up the reshare tree.
45
-	 *
46
-	 * @param string $path
47
-	 */
48
-	static private function moveShareToShare($path) {
49
-		$userFolder = \OC::$server->getUserFolder();
50
-
51
-		// If the user folder can't be constructed (e.g. link share) just return.
52
-		if ($userFolder === null) {
53
-			return;
54
-		}
55
-
56
-		$src = $userFolder->get($path);
57
-
58
-		$shareManager = \OC::$server->getShareManager();
59
-
60
-		$shares = $shareManager->getSharesBy($userFolder->getOwner()->getUID(), \OCP\Share::SHARE_TYPE_USER, $src, false, -1);
61
-		$shares = array_merge($shares, $shareManager->getSharesBy($userFolder->getOwner()->getUID(), \OCP\Share::SHARE_TYPE_GROUP, $src, false, -1));
62
-
63
-		// If the path we move is not a share we don't care
64
-		if (empty($shares)) {
65
-			return;
66
-		}
67
-
68
-		// Check if the destination is inside a share
69
-		$mountManager = \OC::$server->getMountManager();
70
-		$dstMount = $mountManager->find($src->getPath());
71
-		if (!($dstMount instanceof \OCA\Files_Sharing\SharedMount)) {
72
-			return;
73
-		}
74
-
75
-		$newOwner = $dstMount->getShare()->getShareOwner();
76
-
77
-		//Ownership is moved over
78
-		foreach ($shares as $share) {
79
-			/** @var \OCP\Share\IShare $share */
80
-			$share->setShareOwner($newOwner);
81
-			$shareManager->updateShare($share);
82
-		}
83
-	}
84
-
85
-	/**
86
-	 * rename mount point from the children if the parent was renamed
87
-	 *
88
-	 * @param string $oldPath old path relative to data/user/files
89
-	 * @param string $newPath new path relative to data/user/files
90
-	 */
91
-	static private function renameChildren($oldPath, $newPath) {
92
-
93
-		$absNewPath =  \OC\Files\Filesystem::normalizePath('/' . \OCP\User::getUser() . '/files/' . $newPath);
94
-		$absOldPath =  \OC\Files\Filesystem::normalizePath('/' . \OCP\User::getUser() . '/files/' . $oldPath);
95
-
96
-		$mountManager = \OC\Files\Filesystem::getMountManager();
97
-		$mountedShares = $mountManager->findIn('/' . \OCP\User::getUser() . '/files/' . $oldPath);
98
-		foreach ($mountedShares as $mount) {
99
-			if ($mount->getStorage()->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')) {
100
-				$mountPoint = $mount->getMountPoint();
101
-				$target = str_replace($absOldPath, $absNewPath, $mountPoint);
102
-				$mount->moveMount($target);
103
-			}
104
-		}
105
-	}
30
+    /**
31
+     * @param array $params
32
+     */
33
+    static public function renameHook($params) {
34
+        self::renameChildren($params['oldpath'], $params['newpath']);
35
+        self::moveShareToShare($params['newpath']);
36
+    }
37
+
38
+    /**
39
+     * Fix for https://github.com/owncloud/core/issues/20769
40
+     *
41
+     * The owner is allowed to move their files (if they are shared) into a receiving folder
42
+     * In this case we need to update the parent of the moved share. Since they are
43
+     * effectively handing over ownership of the file the rest of the code needs to know
44
+     * they need to build up the reshare tree.
45
+     *
46
+     * @param string $path
47
+     */
48
+    static private function moveShareToShare($path) {
49
+        $userFolder = \OC::$server->getUserFolder();
50
+
51
+        // If the user folder can't be constructed (e.g. link share) just return.
52
+        if ($userFolder === null) {
53
+            return;
54
+        }
55
+
56
+        $src = $userFolder->get($path);
57
+
58
+        $shareManager = \OC::$server->getShareManager();
59
+
60
+        $shares = $shareManager->getSharesBy($userFolder->getOwner()->getUID(), \OCP\Share::SHARE_TYPE_USER, $src, false, -1);
61
+        $shares = array_merge($shares, $shareManager->getSharesBy($userFolder->getOwner()->getUID(), \OCP\Share::SHARE_TYPE_GROUP, $src, false, -1));
62
+
63
+        // If the path we move is not a share we don't care
64
+        if (empty($shares)) {
65
+            return;
66
+        }
67
+
68
+        // Check if the destination is inside a share
69
+        $mountManager = \OC::$server->getMountManager();
70
+        $dstMount = $mountManager->find($src->getPath());
71
+        if (!($dstMount instanceof \OCA\Files_Sharing\SharedMount)) {
72
+            return;
73
+        }
74
+
75
+        $newOwner = $dstMount->getShare()->getShareOwner();
76
+
77
+        //Ownership is moved over
78
+        foreach ($shares as $share) {
79
+            /** @var \OCP\Share\IShare $share */
80
+            $share->setShareOwner($newOwner);
81
+            $shareManager->updateShare($share);
82
+        }
83
+    }
84
+
85
+    /**
86
+     * rename mount point from the children if the parent was renamed
87
+     *
88
+     * @param string $oldPath old path relative to data/user/files
89
+     * @param string $newPath new path relative to data/user/files
90
+     */
91
+    static private function renameChildren($oldPath, $newPath) {
92
+
93
+        $absNewPath =  \OC\Files\Filesystem::normalizePath('/' . \OCP\User::getUser() . '/files/' . $newPath);
94
+        $absOldPath =  \OC\Files\Filesystem::normalizePath('/' . \OCP\User::getUser() . '/files/' . $oldPath);
95
+
96
+        $mountManager = \OC\Files\Filesystem::getMountManager();
97
+        $mountedShares = $mountManager->findIn('/' . \OCP\User::getUser() . '/files/' . $oldPath);
98
+        foreach ($mountedShares as $mount) {
99
+            if ($mount->getStorage()->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')) {
100
+                $mountPoint = $mount->getMountPoint();
101
+                $target = str_replace($absOldPath, $absNewPath, $mountPoint);
102
+                $mount->moveMount($target);
103
+            }
104
+        }
105
+    }
106 106
 
107 107
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/Helper.php 1 patch
Indentation   +237 added lines, -237 removed lines patch added patch discarded remove patch
@@ -36,242 +36,242 @@
 block discarded – undo
36 36
 
37 37
 class Helper {
38 38
 
39
-	public static function registerHooks() {
40
-		\OCP\Util::connectHook('OC_Filesystem', 'post_rename', '\OCA\Files_Sharing\Updater', 'renameHook');
41
-		\OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\OCA\Files_Sharing\Hooks', 'unshareChildren');
42
-
43
-		\OCP\Util::connectHook('OC_User', 'post_deleteUser', '\OCA\Files_Sharing\Hooks', 'deleteUser');
44
-	}
45
-
46
-	/**
47
-	 * Sets up the filesystem and user for public sharing
48
-	 * @param string $token string share token
49
-	 * @param string $relativePath optional path relative to the share
50
-	 * @param string $password optional password
51
-	 * @return array
52
-	 */
53
-	public static function setupFromToken($token, $relativePath = null, $password = null) {
54
-		\OC_User::setIncognitoMode(true);
55
-
56
-		$shareManager = \OC::$server->getShareManager();
57
-
58
-		try {
59
-			$share = $shareManager->getShareByToken($token);
60
-		} catch (ShareNotFound $e) {
61
-			\OC_Response::setStatus(404);
62
-			\OCP\Util::writeLog('core-preview', 'Passed token parameter is not valid', \OCP\Util::DEBUG);
63
-			exit;
64
-		}
65
-
66
-		\OCP\JSON::checkUserExists($share->getShareOwner());
67
-		\OC_Util::tearDownFS();
68
-		\OC_Util::setupFS($share->getShareOwner());
69
-
70
-
71
-		try {
72
-			$path = Filesystem::getPath($share->getNodeId());
73
-		} catch (NotFoundException $e) {
74
-			\OCP\Util::writeLog('share', 'could not resolve linkItem', \OCP\Util::DEBUG);
75
-			\OC_Response::setStatus(404);
76
-			\OCP\JSON::error(array('success' => false));
77
-			exit();
78
-		}
79
-
80
-		if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK && $share->getPassword() !== null) {
81
-			if (!self::authenticate($share, $password)) {
82
-				\OC_Response::setStatus(403);
83
-				\OCP\JSON::error(array('success' => false));
84
-				exit();
85
-			}
86
-		}
87
-
88
-		$basePath = $path;
89
-
90
-		if ($relativePath !== null && Filesystem::isReadable($basePath . $relativePath)) {
91
-			$path .= Filesystem::normalizePath($relativePath);
92
-		}
93
-
94
-		return array(
95
-			'share' => $share,
96
-			'basePath' => $basePath,
97
-			'realPath' => $path
98
-		);
99
-	}
100
-
101
-	/**
102
-	 * Authenticate link item with the given password
103
-	 * or with the session if no password was given.
104
-	 * @param \OCP\Share\IShare $share
105
-	 * @param string $password optional password
106
-	 *
107
-	 * @return boolean true if authorized, false otherwise
108
-	 */
109
-	public static function authenticate($share, $password = null) {
110
-		$shareManager = \OC::$server->getShareManager();
111
-
112
-		if ($password !== null) {
113
-			if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
114
-				if ($shareManager->checkPassword($share, $password)) {
115
-					\OC::$server->getSession()->set('public_link_authenticated', (string)$share->getId());
116
-					return true;
117
-				}
118
-			}
119
-		} else {
120
-			// not authenticated ?
121
-			if (\OC::$server->getSession()->exists('public_link_authenticated')
122
-				&& \OC::$server->getSession()->get('public_link_authenticated') !== (string)$share->getId()) {
123
-				return true;
124
-			}
125
-		}
126
-		return false;
127
-	}
128
-
129
-	public static function getSharesFromItem($target) {
130
-		$result = array();
131
-		$owner = Filesystem::getOwner($target);
132
-		Filesystem::initMountPoints($owner);
133
-		$info = Filesystem::getFileInfo($target);
134
-		$ownerView = new View('/'.$owner.'/files');
135
-		if ( $owner != User::getUser() ) {
136
-			$path = $ownerView->getPath($info['fileid']);
137
-		} else {
138
-			$path = $target;
139
-		}
140
-
141
-
142
-		$ids = array();
143
-		while ($path !== dirname($path)) {
144
-			$info = $ownerView->getFileInfo($path);
145
-			if ($info instanceof \OC\Files\FileInfo) {
146
-				$ids[] = $info['fileid'];
147
-			} else {
148
-				\OCP\Util::writeLog('sharing', 'No fileinfo available for: ' . $path, \OCP\Util::WARN);
149
-			}
150
-			$path = dirname($path);
151
-		}
152
-
153
-		if (!empty($ids)) {
154
-
155
-			$idList = array_chunk($ids, 99, true);
156
-
157
-			foreach ($idList as $subList) {
158
-				$statement = "SELECT `share_with`, `share_type`, `file_target` FROM `*PREFIX*share` WHERE `file_source` IN (" . implode(',', $subList) . ") AND `share_type` IN (0, 1, 2)";
159
-				$query = \OCP\DB::prepare($statement);
160
-				$r = $query->execute();
161
-				$result = array_merge($result, $r->fetchAll());
162
-			}
163
-		}
164
-
165
-		return $result;
166
-	}
167
-
168
-	/**
169
-	 * get the UID of the owner of the file and the path to the file relative to
170
-	 * owners files folder
171
-	 *
172
-	 * @param $filename
173
-	 * @return array
174
-	 * @throws \OC\User\NoUserException
175
-	 */
176
-	public static function getUidAndFilename($filename) {
177
-		$uid = Filesystem::getOwner($filename);
178
-		$userManager = \OC::$server->getUserManager();
179
-		// if the user with the UID doesn't exists, e.g. because the UID points
180
-		// to a remote user with a federated cloud ID we use the current logged-in
181
-		// user. We need a valid local user to create the share
182
-		if (!$userManager->userExists($uid)) {
183
-			$uid = User::getUser();
184
-		}
185
-		Filesystem::initMountPoints($uid);
186
-		if ( $uid != User::getUser() ) {
187
-			$info = Filesystem::getFileInfo($filename);
188
-			$ownerView = new View('/'.$uid.'/files');
189
-			try {
190
-				$filename = $ownerView->getPath($info['fileid']);
191
-			} catch (NotFoundException $e) {
192
-				$filename = null;
193
-			}
194
-		}
195
-		return [$uid, $filename];
196
-	}
197
-
198
-	/**
199
-	 * Format a path to be relative to the /user/files/ directory
200
-	 * @param string $path the absolute path
201
-	 * @return string e.g. turns '/admin/files/test.txt' into 'test.txt'
202
-	 */
203
-	public static function stripUserFilesPath($path) {
204
-		$trimmed = ltrim($path, '/');
205
-		$split = explode('/', $trimmed);
206
-
207
-		// it is not a file relative to data/user/files
208
-		if (count($split) < 3 || $split[1] !== 'files') {
209
-			return false;
210
-		}
211
-
212
-		$sliced = array_slice($split, 2);
213
-		$relPath = implode('/', $sliced);
214
-
215
-		return $relPath;
216
-	}
217
-
218
-	/**
219
-	 * check if file name already exists and generate unique target
220
-	 *
221
-	 * @param string $path
222
-	 * @param array $excludeList
223
-	 * @param View $view
224
-	 * @return string $path
225
-	 */
226
-	public static function generateUniqueTarget($path, $excludeList, $view) {
227
-		$pathinfo = pathinfo($path);
228
-		$ext = (isset($pathinfo['extension'])) ? '.'.$pathinfo['extension'] : '';
229
-		$name = $pathinfo['filename'];
230
-		$dir = $pathinfo['dirname'];
231
-		$i = 2;
232
-		while ($view->file_exists($path) || in_array($path, $excludeList)) {
233
-			$path = Filesystem::normalizePath($dir . '/' . $name . ' ('.$i.')' . $ext);
234
-			$i++;
235
-		}
236
-
237
-		return $path;
238
-	}
239
-
240
-	/**
241
-	 * get default share folder
242
-	 *
243
-	 * @param \OC\Files\View
244
-	 * @return string
245
-	 */
246
-	public static function getShareFolder($view = null) {
247
-		if ($view === null) {
248
-			$view = Filesystem::getView();
249
-		}
250
-		$shareFolder = \OC::$server->getConfig()->getSystemValue('share_folder', '/');
251
-		$shareFolder = Filesystem::normalizePath($shareFolder);
252
-
253
-		if (!$view->file_exists($shareFolder)) {
254
-			$dir = '';
255
-			$subdirs = explode('/', $shareFolder);
256
-			foreach ($subdirs as $subdir) {
257
-				$dir = $dir . '/' . $subdir;
258
-				if (!$view->is_dir($dir)) {
259
-					$view->mkdir($dir);
260
-				}
261
-			}
262
-		}
263
-
264
-		return $shareFolder;
265
-
266
-	}
267
-
268
-	/**
269
-	 * set default share folder
270
-	 *
271
-	 * @param string $shareFolder
272
-	 */
273
-	public static function setShareFolder($shareFolder) {
274
-		\OC::$server->getConfig()->setSystemValue('share_folder', $shareFolder);
275
-	}
39
+    public static function registerHooks() {
40
+        \OCP\Util::connectHook('OC_Filesystem', 'post_rename', '\OCA\Files_Sharing\Updater', 'renameHook');
41
+        \OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\OCA\Files_Sharing\Hooks', 'unshareChildren');
42
+
43
+        \OCP\Util::connectHook('OC_User', 'post_deleteUser', '\OCA\Files_Sharing\Hooks', 'deleteUser');
44
+    }
45
+
46
+    /**
47
+     * Sets up the filesystem and user for public sharing
48
+     * @param string $token string share token
49
+     * @param string $relativePath optional path relative to the share
50
+     * @param string $password optional password
51
+     * @return array
52
+     */
53
+    public static function setupFromToken($token, $relativePath = null, $password = null) {
54
+        \OC_User::setIncognitoMode(true);
55
+
56
+        $shareManager = \OC::$server->getShareManager();
57
+
58
+        try {
59
+            $share = $shareManager->getShareByToken($token);
60
+        } catch (ShareNotFound $e) {
61
+            \OC_Response::setStatus(404);
62
+            \OCP\Util::writeLog('core-preview', 'Passed token parameter is not valid', \OCP\Util::DEBUG);
63
+            exit;
64
+        }
65
+
66
+        \OCP\JSON::checkUserExists($share->getShareOwner());
67
+        \OC_Util::tearDownFS();
68
+        \OC_Util::setupFS($share->getShareOwner());
69
+
70
+
71
+        try {
72
+            $path = Filesystem::getPath($share->getNodeId());
73
+        } catch (NotFoundException $e) {
74
+            \OCP\Util::writeLog('share', 'could not resolve linkItem', \OCP\Util::DEBUG);
75
+            \OC_Response::setStatus(404);
76
+            \OCP\JSON::error(array('success' => false));
77
+            exit();
78
+        }
79
+
80
+        if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK && $share->getPassword() !== null) {
81
+            if (!self::authenticate($share, $password)) {
82
+                \OC_Response::setStatus(403);
83
+                \OCP\JSON::error(array('success' => false));
84
+                exit();
85
+            }
86
+        }
87
+
88
+        $basePath = $path;
89
+
90
+        if ($relativePath !== null && Filesystem::isReadable($basePath . $relativePath)) {
91
+            $path .= Filesystem::normalizePath($relativePath);
92
+        }
93
+
94
+        return array(
95
+            'share' => $share,
96
+            'basePath' => $basePath,
97
+            'realPath' => $path
98
+        );
99
+    }
100
+
101
+    /**
102
+     * Authenticate link item with the given password
103
+     * or with the session if no password was given.
104
+     * @param \OCP\Share\IShare $share
105
+     * @param string $password optional password
106
+     *
107
+     * @return boolean true if authorized, false otherwise
108
+     */
109
+    public static function authenticate($share, $password = null) {
110
+        $shareManager = \OC::$server->getShareManager();
111
+
112
+        if ($password !== null) {
113
+            if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
114
+                if ($shareManager->checkPassword($share, $password)) {
115
+                    \OC::$server->getSession()->set('public_link_authenticated', (string)$share->getId());
116
+                    return true;
117
+                }
118
+            }
119
+        } else {
120
+            // not authenticated ?
121
+            if (\OC::$server->getSession()->exists('public_link_authenticated')
122
+                && \OC::$server->getSession()->get('public_link_authenticated') !== (string)$share->getId()) {
123
+                return true;
124
+            }
125
+        }
126
+        return false;
127
+    }
128
+
129
+    public static function getSharesFromItem($target) {
130
+        $result = array();
131
+        $owner = Filesystem::getOwner($target);
132
+        Filesystem::initMountPoints($owner);
133
+        $info = Filesystem::getFileInfo($target);
134
+        $ownerView = new View('/'.$owner.'/files');
135
+        if ( $owner != User::getUser() ) {
136
+            $path = $ownerView->getPath($info['fileid']);
137
+        } else {
138
+            $path = $target;
139
+        }
140
+
141
+
142
+        $ids = array();
143
+        while ($path !== dirname($path)) {
144
+            $info = $ownerView->getFileInfo($path);
145
+            if ($info instanceof \OC\Files\FileInfo) {
146
+                $ids[] = $info['fileid'];
147
+            } else {
148
+                \OCP\Util::writeLog('sharing', 'No fileinfo available for: ' . $path, \OCP\Util::WARN);
149
+            }
150
+            $path = dirname($path);
151
+        }
152
+
153
+        if (!empty($ids)) {
154
+
155
+            $idList = array_chunk($ids, 99, true);
156
+
157
+            foreach ($idList as $subList) {
158
+                $statement = "SELECT `share_with`, `share_type`, `file_target` FROM `*PREFIX*share` WHERE `file_source` IN (" . implode(',', $subList) . ") AND `share_type` IN (0, 1, 2)";
159
+                $query = \OCP\DB::prepare($statement);
160
+                $r = $query->execute();
161
+                $result = array_merge($result, $r->fetchAll());
162
+            }
163
+        }
164
+
165
+        return $result;
166
+    }
167
+
168
+    /**
169
+     * get the UID of the owner of the file and the path to the file relative to
170
+     * owners files folder
171
+     *
172
+     * @param $filename
173
+     * @return array
174
+     * @throws \OC\User\NoUserException
175
+     */
176
+    public static function getUidAndFilename($filename) {
177
+        $uid = Filesystem::getOwner($filename);
178
+        $userManager = \OC::$server->getUserManager();
179
+        // if the user with the UID doesn't exists, e.g. because the UID points
180
+        // to a remote user with a federated cloud ID we use the current logged-in
181
+        // user. We need a valid local user to create the share
182
+        if (!$userManager->userExists($uid)) {
183
+            $uid = User::getUser();
184
+        }
185
+        Filesystem::initMountPoints($uid);
186
+        if ( $uid != User::getUser() ) {
187
+            $info = Filesystem::getFileInfo($filename);
188
+            $ownerView = new View('/'.$uid.'/files');
189
+            try {
190
+                $filename = $ownerView->getPath($info['fileid']);
191
+            } catch (NotFoundException $e) {
192
+                $filename = null;
193
+            }
194
+        }
195
+        return [$uid, $filename];
196
+    }
197
+
198
+    /**
199
+     * Format a path to be relative to the /user/files/ directory
200
+     * @param string $path the absolute path
201
+     * @return string e.g. turns '/admin/files/test.txt' into 'test.txt'
202
+     */
203
+    public static function stripUserFilesPath($path) {
204
+        $trimmed = ltrim($path, '/');
205
+        $split = explode('/', $trimmed);
206
+
207
+        // it is not a file relative to data/user/files
208
+        if (count($split) < 3 || $split[1] !== 'files') {
209
+            return false;
210
+        }
211
+
212
+        $sliced = array_slice($split, 2);
213
+        $relPath = implode('/', $sliced);
214
+
215
+        return $relPath;
216
+    }
217
+
218
+    /**
219
+     * check if file name already exists and generate unique target
220
+     *
221
+     * @param string $path
222
+     * @param array $excludeList
223
+     * @param View $view
224
+     * @return string $path
225
+     */
226
+    public static function generateUniqueTarget($path, $excludeList, $view) {
227
+        $pathinfo = pathinfo($path);
228
+        $ext = (isset($pathinfo['extension'])) ? '.'.$pathinfo['extension'] : '';
229
+        $name = $pathinfo['filename'];
230
+        $dir = $pathinfo['dirname'];
231
+        $i = 2;
232
+        while ($view->file_exists($path) || in_array($path, $excludeList)) {
233
+            $path = Filesystem::normalizePath($dir . '/' . $name . ' ('.$i.')' . $ext);
234
+            $i++;
235
+        }
236
+
237
+        return $path;
238
+    }
239
+
240
+    /**
241
+     * get default share folder
242
+     *
243
+     * @param \OC\Files\View
244
+     * @return string
245
+     */
246
+    public static function getShareFolder($view = null) {
247
+        if ($view === null) {
248
+            $view = Filesystem::getView();
249
+        }
250
+        $shareFolder = \OC::$server->getConfig()->getSystemValue('share_folder', '/');
251
+        $shareFolder = Filesystem::normalizePath($shareFolder);
252
+
253
+        if (!$view->file_exists($shareFolder)) {
254
+            $dir = '';
255
+            $subdirs = explode('/', $shareFolder);
256
+            foreach ($subdirs as $subdir) {
257
+                $dir = $dir . '/' . $subdir;
258
+                if (!$view->is_dir($dir)) {
259
+                    $view->mkdir($dir);
260
+                }
261
+            }
262
+        }
263
+
264
+        return $shareFolder;
265
+
266
+    }
267
+
268
+    /**
269
+     * set default share folder
270
+     *
271
+     * @param string $shareFolder
272
+     */
273
+    public static function setShareFolder($shareFolder) {
274
+        \OC::$server->getConfig()->setSystemValue('share_folder', $shareFolder);
275
+    }
276 276
 
277 277
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/DeleteOrphanedSharesJob.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -31,36 +31,36 @@
 block discarded – undo
31 31
  */
32 32
 class DeleteOrphanedSharesJob extends TimedJob {
33 33
 
34
-	/**
35
-	 * Default interval in minutes
36
-	 *
37
-	 * @var int $defaultIntervalMin
38
-	 **/
39
-	protected $defaultIntervalMin = 15;
34
+    /**
35
+     * Default interval in minutes
36
+     *
37
+     * @var int $defaultIntervalMin
38
+     **/
39
+    protected $defaultIntervalMin = 15;
40 40
 
41
-	/**
42
-	 * sets the correct interval for this timed job
43
-	 */
44
-	public function __construct(){
45
-		$this->interval = $this->defaultIntervalMin * 60;
46
-	}
41
+    /**
42
+     * sets the correct interval for this timed job
43
+     */
44
+    public function __construct(){
45
+        $this->interval = $this->defaultIntervalMin * 60;
46
+    }
47 47
 
48
-	/**
49
-	 * Makes the background job do its work
50
-	 *
51
-	 * @param array $argument unused argument
52
-	 */
53
-	public function run($argument) {
54
-		$connection = \OC::$server->getDatabaseConnection();
55
-		$logger = \OC::$server->getLogger();
48
+    /**
49
+     * Makes the background job do its work
50
+     *
51
+     * @param array $argument unused argument
52
+     */
53
+    public function run($argument) {
54
+        $connection = \OC::$server->getDatabaseConnection();
55
+        $logger = \OC::$server->getLogger();
56 56
 
57
-		$sql =
58
-			'DELETE FROM `*PREFIX*share` ' .
59
-			'WHERE `item_type` in (\'file\', \'folder\') ' .
60
-			'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)';
57
+        $sql =
58
+            'DELETE FROM `*PREFIX*share` ' .
59
+            'WHERE `item_type` in (\'file\', \'folder\') ' .
60
+            'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)';
61 61
 
62
-		$deletedEntries = $connection->executeUpdate($sql);
63
-		$logger->debug("$deletedEntries orphaned share(s) deleted", ['app' => 'DeleteOrphanedSharesJob']);
64
-	}
62
+        $deletedEntries = $connection->executeUpdate($sql);
63
+        $logger->debug("$deletedEntries orphaned share(s) deleted", ['app' => 'DeleteOrphanedSharesJob']);
64
+    }
65 65
 
66 66
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/Middleware/OCSShareAPIMiddleware.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -10,43 +10,43 @@
 block discarded – undo
10 10
 use OCP\Share\IManager;
11 11
 
12 12
 class OCSShareAPIMiddleware extends Middleware {
13
-	/** @var IManager */
14
-	private $shareManager;
15
-	/** @var IL10N */
16
-	private $l;
13
+    /** @var IManager */
14
+    private $shareManager;
15
+    /** @var IL10N */
16
+    private $l;
17 17
 
18
-	public function __construct(IManager $shareManager,
19
-								IL10N $l) {
20
-		$this->shareManager = $shareManager;
21
-		$this->l = $l;
22
-	}
18
+    public function __construct(IManager $shareManager,
19
+                                IL10N $l) {
20
+        $this->shareManager = $shareManager;
21
+        $this->l = $l;
22
+    }
23 23
 
24
-	/**
25
-	 * @param \OCP\AppFramework\Controller $controller
26
-	 * @param string $methodName
27
-	 *
28
-	 * @throws OCSNotFoundException
29
-	 */
30
-	public function beforeController($controller, $methodName) {
31
-		if ($controller instanceof ShareAPIController) {
32
-			if (!$this->shareManager->shareApiEnabled()) {
33
-				throw new OCSNotFoundException($this->l->t('Share API is disabled'));
34
-			}
35
-		}
36
-	}
24
+    /**
25
+     * @param \OCP\AppFramework\Controller $controller
26
+     * @param string $methodName
27
+     *
28
+     * @throws OCSNotFoundException
29
+     */
30
+    public function beforeController($controller, $methodName) {
31
+        if ($controller instanceof ShareAPIController) {
32
+            if (!$this->shareManager->shareApiEnabled()) {
33
+                throw new OCSNotFoundException($this->l->t('Share API is disabled'));
34
+            }
35
+        }
36
+    }
37 37
 
38
-	/**
39
-	 * @param \OCP\AppFramework\Controller $controller
40
-	 * @param string $methodName
41
-	 * @param Response $response
42
-	 * @return Response
43
-	 */
44
-	public function afterController($controller, $methodName, Response $response) {
45
-		if ($controller instanceof ShareAPIController) {
46
-			/** @var ShareAPIController $controller */
47
-			$controller->cleanup();
48
-		}
38
+    /**
39
+     * @param \OCP\AppFramework\Controller $controller
40
+     * @param string $methodName
41
+     * @param Response $response
42
+     * @return Response
43
+     */
44
+    public function afterController($controller, $methodName, Response $response) {
45
+        if ($controller instanceof ShareAPIController) {
46
+            /** @var ShareAPIController $controller */
47
+            $controller->cleanup();
48
+        }
49 49
 
50
-		return $response;
51
-	}
50
+        return $response;
51
+    }
52 52
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php 1 patch
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -45,20 +45,20 @@  discard block
 block discarded – undo
45 45
  */
46 46
 class SharingCheckMiddleware extends Middleware {
47 47
 
48
-	/** @var string */
49
-	protected $appName;
50
-	/** @var IConfig */
51
-	protected $config;
52
-	/** @var IAppManager */
53
-	protected $appManager;
54
-	/** @var IControllerMethodReflector */
55
-	protected $reflector;
56
-	/** @var IManager */
57
-	protected $shareManager;
58
-	/** @var IRequest */
59
-	protected $request;
60
-
61
-	/***
48
+    /** @var string */
49
+    protected $appName;
50
+    /** @var IConfig */
51
+    protected $config;
52
+    /** @var IAppManager */
53
+    protected $appManager;
54
+    /** @var IControllerMethodReflector */
55
+    protected $reflector;
56
+    /** @var IManager */
57
+    protected $shareManager;
58
+    /** @var IRequest */
59
+    protected $request;
60
+
61
+    /***
62 62
 	 * @param string $appName
63 63
 	 * @param IConfig $config
64 64
 	 * @param IAppManager $appManager
@@ -66,117 +66,117 @@  discard block
 block discarded – undo
66 66
 	 * @param IManager $shareManager
67 67
 	 * @param IRequest $request
68 68
 	 */
69
-	public function __construct($appName,
70
-								IConfig $config,
71
-								IAppManager $appManager,
72
-								IControllerMethodReflector $reflector,
73
-								IManager $shareManager,
74
-								IRequest $request
75
-								) {
76
-		$this->appName = $appName;
77
-		$this->config = $config;
78
-		$this->appManager = $appManager;
79
-		$this->reflector = $reflector;
80
-		$this->shareManager = $shareManager;
81
-		$this->request = $request;
82
-	}
83
-
84
-	/**
85
-	 * Check if sharing is enabled before the controllers is executed
86
-	 *
87
-	 * @param \OCP\AppFramework\Controller $controller
88
-	 * @param string $methodName
89
-	 * @throws NotFoundException
90
-	 * @throws S2SException
91
-	 */
92
-	public function beforeController($controller, $methodName) {
93
-		if(!$this->isSharingEnabled()) {
94
-			throw new NotFoundException('Sharing is disabled.');
95
-		}
96
-
97
-		if ($controller instanceof ExternalSharesController &&
98
-			!$this->externalSharesChecks()) {
99
-			throw new S2SException('Federated sharing not allowed');
100
-		} else if ($controller instanceof ShareController) {
101
-			$token = $this->request->getParam('token');
102
-			$share = $this->shareManager->getShareByToken($token);
103
-			if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK
104
-				&& !$this->isLinkSharingEnabled()) {
105
-				throw new NotFoundException('Link sharing is disabled');
106
-			}
107
-		}
108
-	}
109
-
110
-	/**
111
-	 * Return 404 page in case of a not found exception
112
-	 *
113
-	 * @param \OCP\AppFramework\Controller $controller
114
-	 * @param string $methodName
115
-	 * @param \Exception $exception
116
-	 * @return NotFoundResponse
117
-	 * @throws \Exception
118
-	 */
119
-	public function afterException($controller, $methodName, \Exception $exception) {
120
-		if(is_a($exception, '\OCP\Files\NotFoundException')) {
121
-			return new NotFoundResponse();
122
-		}
123
-
124
-		if (is_a($exception, '\OCA\Files_Sharing\Exceptions\S2SException')) {
125
-			return new JSONResponse($exception->getMessage(), 405);
126
-		}
127
-
128
-		throw $exception;
129
-	}
130
-
131
-	/**
132
-	 * Checks for externalshares controller
133
-	 * @return bool
134
-	 */
135
-	private function externalSharesChecks() {
136
-
137
-		if (!$this->reflector->hasAnnotation('NoIncomingFederatedSharingRequired') &&
138
-			$this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') !== 'yes') {
139
-			return false;
140
-		}
141
-
142
-		if (!$this->reflector->hasAnnotation('NoOutgoingFederatedSharingRequired') &&
143
-		    $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') !== 'yes') {
144
-			return false;
145
-		}
146
-
147
-		return true;
148
-	}
149
-
150
-	/**
151
-	 * Check whether sharing is enabled
152
-	 * @return bool
153
-	 */
154
-	private function isSharingEnabled() {
155
-		// FIXME: This check is done here since the route is globally defined and not inside the files_sharing app
156
-		// Check whether the sharing application is enabled
157
-		if(!$this->appManager->isEnabledForUser($this->appName)) {
158
-			return false;
159
-		}
160
-
161
-		return true;
162
-	}
163
-
164
-	/**
165
-	 * Check if link sharing is allowed
166
-	 * @return bool
167
-	 */
168
-	private function isLinkSharingEnabled() {
169
-		// Check if the shareAPI is enabled
170
-		if ($this->config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') {
171
-			return false;
172
-		}
173
-
174
-		// Check whether public sharing is enabled
175
-		if($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') {
176
-			return false;
177
-		}
178
-
179
-		return true;
180
-	}
69
+    public function __construct($appName,
70
+                                IConfig $config,
71
+                                IAppManager $appManager,
72
+                                IControllerMethodReflector $reflector,
73
+                                IManager $shareManager,
74
+                                IRequest $request
75
+                                ) {
76
+        $this->appName = $appName;
77
+        $this->config = $config;
78
+        $this->appManager = $appManager;
79
+        $this->reflector = $reflector;
80
+        $this->shareManager = $shareManager;
81
+        $this->request = $request;
82
+    }
83
+
84
+    /**
85
+     * Check if sharing is enabled before the controllers is executed
86
+     *
87
+     * @param \OCP\AppFramework\Controller $controller
88
+     * @param string $methodName
89
+     * @throws NotFoundException
90
+     * @throws S2SException
91
+     */
92
+    public function beforeController($controller, $methodName) {
93
+        if(!$this->isSharingEnabled()) {
94
+            throw new NotFoundException('Sharing is disabled.');
95
+        }
96
+
97
+        if ($controller instanceof ExternalSharesController &&
98
+            !$this->externalSharesChecks()) {
99
+            throw new S2SException('Federated sharing not allowed');
100
+        } else if ($controller instanceof ShareController) {
101
+            $token = $this->request->getParam('token');
102
+            $share = $this->shareManager->getShareByToken($token);
103
+            if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK
104
+                && !$this->isLinkSharingEnabled()) {
105
+                throw new NotFoundException('Link sharing is disabled');
106
+            }
107
+        }
108
+    }
109
+
110
+    /**
111
+     * Return 404 page in case of a not found exception
112
+     *
113
+     * @param \OCP\AppFramework\Controller $controller
114
+     * @param string $methodName
115
+     * @param \Exception $exception
116
+     * @return NotFoundResponse
117
+     * @throws \Exception
118
+     */
119
+    public function afterException($controller, $methodName, \Exception $exception) {
120
+        if(is_a($exception, '\OCP\Files\NotFoundException')) {
121
+            return new NotFoundResponse();
122
+        }
123
+
124
+        if (is_a($exception, '\OCA\Files_Sharing\Exceptions\S2SException')) {
125
+            return new JSONResponse($exception->getMessage(), 405);
126
+        }
127
+
128
+        throw $exception;
129
+    }
130
+
131
+    /**
132
+     * Checks for externalshares controller
133
+     * @return bool
134
+     */
135
+    private function externalSharesChecks() {
136
+
137
+        if (!$this->reflector->hasAnnotation('NoIncomingFederatedSharingRequired') &&
138
+            $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') !== 'yes') {
139
+            return false;
140
+        }
141
+
142
+        if (!$this->reflector->hasAnnotation('NoOutgoingFederatedSharingRequired') &&
143
+            $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') !== 'yes') {
144
+            return false;
145
+        }
146
+
147
+        return true;
148
+    }
149
+
150
+    /**
151
+     * Check whether sharing is enabled
152
+     * @return bool
153
+     */
154
+    private function isSharingEnabled() {
155
+        // FIXME: This check is done here since the route is globally defined and not inside the files_sharing app
156
+        // Check whether the sharing application is enabled
157
+        if(!$this->appManager->isEnabledForUser($this->appName)) {
158
+            return false;
159
+        }
160
+
161
+        return true;
162
+    }
163
+
164
+    /**
165
+     * Check if link sharing is allowed
166
+     * @return bool
167
+     */
168
+    private function isLinkSharingEnabled() {
169
+        // Check if the shareAPI is enabled
170
+        if ($this->config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') {
171
+            return false;
172
+        }
173
+
174
+        // Check whether public sharing is enabled
175
+        if($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') {
176
+            return false;
177
+        }
178
+
179
+        return true;
180
+    }
181 181
 
182 182
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/SharedPropagator.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -26,19 +26,19 @@
 block discarded – undo
26 26
 use OC\Files\Cache\Propagator;
27 27
 
28 28
 class SharedPropagator extends Propagator {
29
-	/**
30
-	 * @var \OCA\Files_Sharing\SharedStorage
31
-	 */
32
-	protected $storage;
29
+    /**
30
+     * @var \OCA\Files_Sharing\SharedStorage
31
+     */
32
+    protected $storage;
33 33
 
34
-	/**
35
-	 * @param string $internalPath
36
-	 * @param int $time
37
-	 * @param int $sizeDifference
38
-	 */
39
-	public function propagateChange($internalPath, $time, $sizeDifference = 0) {
40
-		/** @var \OC\Files\Storage\Storage $storage */
41
-		list($storage, $sourceInternalPath) = $this->storage->resolvePath($internalPath);
42
-		$storage->getPropagator()->propagateChange($sourceInternalPath, $time, $sizeDifference);
43
-	}
34
+    /**
35
+     * @param string $internalPath
36
+     * @param int $time
37
+     * @param int $sizeDifference
38
+     */
39
+    public function propagateChange($internalPath, $time, $sizeDifference = 0) {
40
+        /** @var \OC\Files\Storage\Storage $storage */
41
+        list($storage, $sourceInternalPath) = $this->storage->resolvePath($internalPath);
42
+        $storage->getPropagator()->propagateChange($sourceInternalPath, $time, $sizeDifference);
43
+    }
44 44
 }
Please login to merge, or discard this patch.