Passed
Push — master ( 171373...275f15 )
by Morris
12:13
created
apps/files_external/lib/Lib/PersonalMount.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -34,60 +34,60 @@
 block discarded – undo
34 34
  * Person mount points can be moved by the user
35 35
  */
36 36
 class PersonalMount extends ExternalMountPoint implements MoveableMount {
37
-	/** @var UserStoragesService */
38
-	protected $storagesService;
37
+    /** @var UserStoragesService */
38
+    protected $storagesService;
39 39
 
40
-	/** @var int */
41
-	protected $numericStorageId;
40
+    /** @var int */
41
+    protected $numericStorageId;
42 42
 
43
-	/**
44
-	 * @param UserStoragesService $storagesService
45
-	 * @param int $storageId
46
-	 * @param IStorage $storage
47
-	 * @param string $mountpoint
48
-	 * @param array $arguments (optional) configuration for the storage backend
49
-	 * @param \OCP\Files\Storage\IStorageFactory $loader
50
-	 * @param array $mountOptions mount specific options
51
-	 */
52
-	public function __construct(
53
-		UserStoragesService $storagesService,
54
-		StorageConfig $storageConfig,
55
-		$storageId,
56
-		$storage,
57
-		$mountpoint,
58
-		$arguments = null,
59
-		$loader = null,
60
-		$mountOptions = null,
61
-		$mountId = null
62
-	) {
63
-		parent::__construct($storageConfig, $storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId);
64
-		$this->storagesService = $storagesService;
65
-		$this->numericStorageId = $storageId;
66
-	}
43
+    /**
44
+     * @param UserStoragesService $storagesService
45
+     * @param int $storageId
46
+     * @param IStorage $storage
47
+     * @param string $mountpoint
48
+     * @param array $arguments (optional) configuration for the storage backend
49
+     * @param \OCP\Files\Storage\IStorageFactory $loader
50
+     * @param array $mountOptions mount specific options
51
+     */
52
+    public function __construct(
53
+        UserStoragesService $storagesService,
54
+        StorageConfig $storageConfig,
55
+        $storageId,
56
+        $storage,
57
+        $mountpoint,
58
+        $arguments = null,
59
+        $loader = null,
60
+        $mountOptions = null,
61
+        $mountId = null
62
+    ) {
63
+        parent::__construct($storageConfig, $storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId);
64
+        $this->storagesService = $storagesService;
65
+        $this->numericStorageId = $storageId;
66
+    }
67 67
 
68
-	/**
69
-	 * Move the mount point to $target
70
-	 *
71
-	 * @param string $target the target mount point
72
-	 * @return bool
73
-	 */
74
-	public function moveMount($target) {
75
-		$storage = $this->storagesService->getStorage($this->numericStorageId);
76
-		// remove "/$user/files" prefix
77
-		$targetParts = explode('/', trim($target, '/'), 3);
78
-		$storage->setMountPoint($targetParts[2]);
79
-		$this->storagesService->updateStorage($storage);
80
-		$this->setMountPoint($target);
81
-		return true;
82
-	}
68
+    /**
69
+     * Move the mount point to $target
70
+     *
71
+     * @param string $target the target mount point
72
+     * @return bool
73
+     */
74
+    public function moveMount($target) {
75
+        $storage = $this->storagesService->getStorage($this->numericStorageId);
76
+        // remove "/$user/files" prefix
77
+        $targetParts = explode('/', trim($target, '/'), 3);
78
+        $storage->setMountPoint($targetParts[2]);
79
+        $this->storagesService->updateStorage($storage);
80
+        $this->setMountPoint($target);
81
+        return true;
82
+    }
83 83
 
84
-	/**
85
-	 * Remove the mount points
86
-	 *
87
-	 * @return bool
88
-	 */
89
-	public function removeMount() {
90
-		$this->storagesService->removeStorage($this->numericStorageId);
91
-		return true;
92
-	}
84
+    /**
85
+     * Remove the mount points
86
+     *
87
+     * @return bool
88
+     */
89
+    public function removeMount() {
90
+        $this->storagesService->removeStorage($this->numericStorageId);
91
+        return true;
92
+    }
93 93
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Config/ConfigAdapter.php 2 patches
Indentation   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -47,145 +47,145 @@
 block discarded – undo
47 47
  */
48 48
 class ConfigAdapter implements IMountProvider {
49 49
 
50
-	/** @var UserStoragesService */
51
-	private $userStoragesService;
52
-
53
-	/** @var UserGlobalStoragesService */
54
-	private $userGlobalStoragesService;
55
-	/** @var StorageMigrator  */
56
-	private $migrator;
57
-
58
-	/**
59
-	 * @param UserStoragesService $userStoragesService
60
-	 * @param UserGlobalStoragesService $userGlobalStoragesService
61
-	 * @param StorageMigrator $migrator
62
-	 */
63
-	public function __construct(
64
-		UserStoragesService $userStoragesService,
65
-		UserGlobalStoragesService $userGlobalStoragesService,
66
-		StorageMigrator $migrator
67
-	) {
68
-		$this->userStoragesService = $userStoragesService;
69
-		$this->userGlobalStoragesService = $userGlobalStoragesService;
70
-		$this->migrator = $migrator;
71
-	}
72
-
73
-	/**
74
-	 * Process storage ready for mounting
75
-	 *
76
-	 * @param StorageConfig $storage
77
-	 * @param IUser $user
78
-	 * @throws \OCP\AppFramework\QueryException
79
-	 */
80
-	private function prepareStorageConfig(StorageConfig &$storage, IUser $user) {
81
-		foreach ($storage->getBackendOptions() as $option => $value) {
82
-			$storage->setBackendOption($option, \OCA\Files_External\MountConfig::substitutePlaceholdersInConfig($value, $user->getUID()));
83
-		}
84
-
85
-		$objectStore = $storage->getBackendOption('objectstore');
86
-		if ($objectStore) {
87
-			$objectClass = $objectStore['class'];
88
-			if (!is_subclass_of($objectClass, '\OCP\Files\ObjectStore\IObjectStore')) {
89
-				throw new \InvalidArgumentException('Invalid object store');
90
-			}
91
-			$storage->setBackendOption('objectstore', new $objectClass($objectStore));
92
-		}
93
-
94
-		$storage->getAuthMechanism()->manipulateStorageConfig($storage, $user);
95
-		$storage->getBackend()->manipulateStorageConfig($storage, $user);
96
-	}
97
-
98
-	/**
99
-	 * Construct the storage implementation
100
-	 *
101
-	 * @param StorageConfig $storageConfig
102
-	 * @return Storage
103
-	 */
104
-	private function constructStorage(StorageConfig $storageConfig) {
105
-		$class = $storageConfig->getBackend()->getStorageClass();
106
-		$storage = new $class($storageConfig->getBackendOptions());
107
-
108
-		// auth mechanism should fire first
109
-		$storage = $storageConfig->getBackend()->wrapStorage($storage);
110
-		$storage = $storageConfig->getAuthMechanism()->wrapStorage($storage);
111
-
112
-		return $storage;
113
-	}
114
-
115
-	/**
116
-	 * Get all mountpoints applicable for the user
117
-	 *
118
-	 * @param \OCP\IUser $user
119
-	 * @param \OCP\Files\Storage\IStorageFactory $loader
120
-	 * @return \OCP\Files\Mount\IMountPoint[]
121
-	 */
122
-	public function getMountsForUser(IUser $user, IStorageFactory $loader) {
123
-		$this->migrator->migrateUser($user);
124
-
125
-		$this->userStoragesService->setUser($user);
126
-		$this->userGlobalStoragesService->setUser($user);
127
-
128
-		$storageConfigs = $this->userGlobalStoragesService->getAllStoragesForUser();
129
-
130
-		$storages = array_map(function (StorageConfig $storageConfig) use ($user) {
131
-			try {
132
-				$this->prepareStorageConfig($storageConfig, $user);
133
-				return $this->constructStorage($storageConfig);
134
-			} catch (\Exception $e) {
135
-				// propagate exception into filesystem
136
-				return new FailedStorage(['exception' => $e]);
137
-			}
138
-		}, $storageConfigs);
139
-
140
-
141
-		\OC\Files\Cache\Storage::getGlobalCache()->loadForStorageIds(array_map(function (Storage\IStorage $storage) {
142
-			return $storage->getId();
143
-		}, $storages));
144
-
145
-		$availableStorages = array_map(function (Storage\IStorage $storage, StorageConfig $storageConfig) {
146
-			try {
147
-				$availability = $storage->getAvailability();
148
-				if (!$availability['available'] && !Availability::shouldRecheck($availability)) {
149
-					$storage = new FailedStorage([
150
-						'exception' => new StorageNotAvailableException('Storage with mount id ' . $storageConfig->getId() . ' is not available')
151
-					]);
152
-				}
153
-			} catch (\Exception $e) {
154
-				// propagate exception into filesystem
155
-				$storage = new FailedStorage(['exception' => $e]);
156
-			}
157
-			return $storage;
158
-		}, $storages, $storageConfigs);
159
-
160
-		$mounts = array_map(function (StorageConfig $storageConfig, Storage\IStorage $storage) use ($user, $loader) {
161
-			if ($storageConfig->getType() === StorageConfig::MOUNT_TYPE_PERSONAl) {
162
-				return new PersonalMount(
163
-					$this->userStoragesService,
164
-					$storageConfig,
165
-					$storageConfig->getId(),
166
-					$storage,
167
-					'/' . $user->getUID() . '/files' . $storageConfig->getMountPoint(),
168
-					null,
169
-					$loader,
170
-					$storageConfig->getMountOptions(),
171
-					$storageConfig->getId()
172
-				);
173
-			} else {
174
-				return new ExternalMountPoint(
175
-					$storageConfig,
176
-					$storage,
177
-					'/' . $user->getUID() . '/files' . $storageConfig->getMountPoint(),
178
-					null,
179
-					$loader,
180
-					$storageConfig->getMountOptions(),
181
-					$storageConfig->getId()
182
-				);
183
-			}
184
-		}, $storageConfigs, $availableStorages);
185
-
186
-		$this->userStoragesService->resetUser();
187
-		$this->userGlobalStoragesService->resetUser();
188
-
189
-		return $mounts;
190
-	}
50
+    /** @var UserStoragesService */
51
+    private $userStoragesService;
52
+
53
+    /** @var UserGlobalStoragesService */
54
+    private $userGlobalStoragesService;
55
+    /** @var StorageMigrator  */
56
+    private $migrator;
57
+
58
+    /**
59
+     * @param UserStoragesService $userStoragesService
60
+     * @param UserGlobalStoragesService $userGlobalStoragesService
61
+     * @param StorageMigrator $migrator
62
+     */
63
+    public function __construct(
64
+        UserStoragesService $userStoragesService,
65
+        UserGlobalStoragesService $userGlobalStoragesService,
66
+        StorageMigrator $migrator
67
+    ) {
68
+        $this->userStoragesService = $userStoragesService;
69
+        $this->userGlobalStoragesService = $userGlobalStoragesService;
70
+        $this->migrator = $migrator;
71
+    }
72
+
73
+    /**
74
+     * Process storage ready for mounting
75
+     *
76
+     * @param StorageConfig $storage
77
+     * @param IUser $user
78
+     * @throws \OCP\AppFramework\QueryException
79
+     */
80
+    private function prepareStorageConfig(StorageConfig &$storage, IUser $user) {
81
+        foreach ($storage->getBackendOptions() as $option => $value) {
82
+            $storage->setBackendOption($option, \OCA\Files_External\MountConfig::substitutePlaceholdersInConfig($value, $user->getUID()));
83
+        }
84
+
85
+        $objectStore = $storage->getBackendOption('objectstore');
86
+        if ($objectStore) {
87
+            $objectClass = $objectStore['class'];
88
+            if (!is_subclass_of($objectClass, '\OCP\Files\ObjectStore\IObjectStore')) {
89
+                throw new \InvalidArgumentException('Invalid object store');
90
+            }
91
+            $storage->setBackendOption('objectstore', new $objectClass($objectStore));
92
+        }
93
+
94
+        $storage->getAuthMechanism()->manipulateStorageConfig($storage, $user);
95
+        $storage->getBackend()->manipulateStorageConfig($storage, $user);
96
+    }
97
+
98
+    /**
99
+     * Construct the storage implementation
100
+     *
101
+     * @param StorageConfig $storageConfig
102
+     * @return Storage
103
+     */
104
+    private function constructStorage(StorageConfig $storageConfig) {
105
+        $class = $storageConfig->getBackend()->getStorageClass();
106
+        $storage = new $class($storageConfig->getBackendOptions());
107
+
108
+        // auth mechanism should fire first
109
+        $storage = $storageConfig->getBackend()->wrapStorage($storage);
110
+        $storage = $storageConfig->getAuthMechanism()->wrapStorage($storage);
111
+
112
+        return $storage;
113
+    }
114
+
115
+    /**
116
+     * Get all mountpoints applicable for the user
117
+     *
118
+     * @param \OCP\IUser $user
119
+     * @param \OCP\Files\Storage\IStorageFactory $loader
120
+     * @return \OCP\Files\Mount\IMountPoint[]
121
+     */
122
+    public function getMountsForUser(IUser $user, IStorageFactory $loader) {
123
+        $this->migrator->migrateUser($user);
124
+
125
+        $this->userStoragesService->setUser($user);
126
+        $this->userGlobalStoragesService->setUser($user);
127
+
128
+        $storageConfigs = $this->userGlobalStoragesService->getAllStoragesForUser();
129
+
130
+        $storages = array_map(function (StorageConfig $storageConfig) use ($user) {
131
+            try {
132
+                $this->prepareStorageConfig($storageConfig, $user);
133
+                return $this->constructStorage($storageConfig);
134
+            } catch (\Exception $e) {
135
+                // propagate exception into filesystem
136
+                return new FailedStorage(['exception' => $e]);
137
+            }
138
+        }, $storageConfigs);
139
+
140
+
141
+        \OC\Files\Cache\Storage::getGlobalCache()->loadForStorageIds(array_map(function (Storage\IStorage $storage) {
142
+            return $storage->getId();
143
+        }, $storages));
144
+
145
+        $availableStorages = array_map(function (Storage\IStorage $storage, StorageConfig $storageConfig) {
146
+            try {
147
+                $availability = $storage->getAvailability();
148
+                if (!$availability['available'] && !Availability::shouldRecheck($availability)) {
149
+                    $storage = new FailedStorage([
150
+                        'exception' => new StorageNotAvailableException('Storage with mount id ' . $storageConfig->getId() . ' is not available')
151
+                    ]);
152
+                }
153
+            } catch (\Exception $e) {
154
+                // propagate exception into filesystem
155
+                $storage = new FailedStorage(['exception' => $e]);
156
+            }
157
+            return $storage;
158
+        }, $storages, $storageConfigs);
159
+
160
+        $mounts = array_map(function (StorageConfig $storageConfig, Storage\IStorage $storage) use ($user, $loader) {
161
+            if ($storageConfig->getType() === StorageConfig::MOUNT_TYPE_PERSONAl) {
162
+                return new PersonalMount(
163
+                    $this->userStoragesService,
164
+                    $storageConfig,
165
+                    $storageConfig->getId(),
166
+                    $storage,
167
+                    '/' . $user->getUID() . '/files' . $storageConfig->getMountPoint(),
168
+                    null,
169
+                    $loader,
170
+                    $storageConfig->getMountOptions(),
171
+                    $storageConfig->getId()
172
+                );
173
+            } else {
174
+                return new ExternalMountPoint(
175
+                    $storageConfig,
176
+                    $storage,
177
+                    '/' . $user->getUID() . '/files' . $storageConfig->getMountPoint(),
178
+                    null,
179
+                    $loader,
180
+                    $storageConfig->getMountOptions(),
181
+                    $storageConfig->getId()
182
+                );
183
+            }
184
+        }, $storageConfigs, $availableStorages);
185
+
186
+        $this->userStoragesService->resetUser();
187
+        $this->userGlobalStoragesService->resetUser();
188
+
189
+        return $mounts;
190
+    }
191 191
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 
128 128
 		$storageConfigs = $this->userGlobalStoragesService->getAllStoragesForUser();
129 129
 
130
-		$storages = array_map(function (StorageConfig $storageConfig) use ($user) {
130
+		$storages = array_map(function(StorageConfig $storageConfig) use ($user) {
131 131
 			try {
132 132
 				$this->prepareStorageConfig($storageConfig, $user);
133 133
 				return $this->constructStorage($storageConfig);
@@ -138,16 +138,16 @@  discard block
 block discarded – undo
138 138
 		}, $storageConfigs);
139 139
 
140 140
 
141
-		\OC\Files\Cache\Storage::getGlobalCache()->loadForStorageIds(array_map(function (Storage\IStorage $storage) {
141
+		\OC\Files\Cache\Storage::getGlobalCache()->loadForStorageIds(array_map(function(Storage\IStorage $storage) {
142 142
 			return $storage->getId();
143 143
 		}, $storages));
144 144
 
145
-		$availableStorages = array_map(function (Storage\IStorage $storage, StorageConfig $storageConfig) {
145
+		$availableStorages = array_map(function(Storage\IStorage $storage, StorageConfig $storageConfig) {
146 146
 			try {
147 147
 				$availability = $storage->getAvailability();
148 148
 				if (!$availability['available'] && !Availability::shouldRecheck($availability)) {
149 149
 					$storage = new FailedStorage([
150
-						'exception' => new StorageNotAvailableException('Storage with mount id ' . $storageConfig->getId() . ' is not available')
150
+						'exception' => new StorageNotAvailableException('Storage with mount id '.$storageConfig->getId().' is not available')
151 151
 					]);
152 152
 				}
153 153
 			} catch (\Exception $e) {
@@ -157,14 +157,14 @@  discard block
 block discarded – undo
157 157
 			return $storage;
158 158
 		}, $storages, $storageConfigs);
159 159
 
160
-		$mounts = array_map(function (StorageConfig $storageConfig, Storage\IStorage $storage) use ($user, $loader) {
160
+		$mounts = array_map(function(StorageConfig $storageConfig, Storage\IStorage $storage) use ($user, $loader) {
161 161
 			if ($storageConfig->getType() === StorageConfig::MOUNT_TYPE_PERSONAl) {
162 162
 				return new PersonalMount(
163 163
 					$this->userStoragesService,
164 164
 					$storageConfig,
165 165
 					$storageConfig->getId(),
166 166
 					$storage,
167
-					'/' . $user->getUID() . '/files' . $storageConfig->getMountPoint(),
167
+					'/'.$user->getUID().'/files'.$storageConfig->getMountPoint(),
168 168
 					null,
169 169
 					$loader,
170 170
 					$storageConfig->getMountOptions(),
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 				return new ExternalMountPoint(
175 175
 					$storageConfig,
176 176
 					$storage,
177
-					'/' . $user->getUID() . '/files' . $storageConfig->getMountPoint(),
177
+					'/'.$user->getUID().'/files'.$storageConfig->getMountPoint(),
178 178
 					null,
179 179
 					$loader,
180 180
 					$storageConfig->getMountOptions(),
Please login to merge, or discard this patch.
apps/files_external/lib/Config/ExternalMountPoint.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -29,15 +29,15 @@
 block discarded – undo
29 29
 
30 30
 class ExternalMountPoint extends MountPoint {
31 31
 
32
-	/** @var StorageConfig */
33
-	protected $storageConfig;
32
+    /** @var StorageConfig */
33
+    protected $storageConfig;
34 34
 
35
-	public function __construct(StorageConfig $storageConfig, $storage, $mountpoint, $arguments = null, $loader = null, $mountOptions = null, $mountId = null) {
36
-		$this->storageConfig = $storageConfig;
37
-		parent::__construct($storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId);
38
-	}
35
+    public function __construct(StorageConfig $storageConfig, $storage, $mountpoint, $arguments = null, $loader = null, $mountOptions = null, $mountId = null) {
36
+        $this->storageConfig = $storageConfig;
37
+        parent::__construct($storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId);
38
+    }
39 39
 
40
-	public function getMountType() {
41
-		return ($this->storageConfig->getAuthMechanism() instanceof SessionCredentials) ? 'external-session' : 'external';
42
-	}
40
+    public function getMountType() {
41
+        return ($this->storageConfig->getAuthMechanism() instanceof SessionCredentials) ? 'external-session' : 'external';
42
+    }
43 43
 }
Please login to merge, or discard this patch.