Passed
Push — master ( 38edc6...bdb152 )
by Julius
13:33 queued 10s
created
lib/private/Files/Mount/MountPoint.php 2 patches
Indentation   +225 added lines, -225 removed lines patch added patch discarded remove patch
@@ -37,253 +37,253 @@
 block discarded – undo
37 37
 use OCP\ILogger;
38 38
 
39 39
 class MountPoint implements IMountPoint {
40
-	/**
41
-	 * @var \OC\Files\Storage\Storage|null $storage
42
-	 */
43
-	protected $storage = null;
44
-	protected $class;
45
-	protected $storageId;
46
-	protected $rootId = null;
40
+    /**
41
+     * @var \OC\Files\Storage\Storage|null $storage
42
+     */
43
+    protected $storage = null;
44
+    protected $class;
45
+    protected $storageId;
46
+    protected $rootId = null;
47 47
 
48
-	/**
49
-	 * Configuration options for the storage backend
50
-	 *
51
-	 * @var array
52
-	 */
53
-	protected $arguments = [];
54
-	protected $mountPoint;
48
+    /**
49
+     * Configuration options for the storage backend
50
+     *
51
+     * @var array
52
+     */
53
+    protected $arguments = [];
54
+    protected $mountPoint;
55 55
 
56
-	/**
57
-	 * Mount specific options
58
-	 *
59
-	 * @var array
60
-	 */
61
-	protected $mountOptions = [];
56
+    /**
57
+     * Mount specific options
58
+     *
59
+     * @var array
60
+     */
61
+    protected $mountOptions = [];
62 62
 
63
-	/**
64
-	 * @var \OC\Files\Storage\StorageFactory $loader
65
-	 */
66
-	private $loader;
63
+    /**
64
+     * @var \OC\Files\Storage\StorageFactory $loader
65
+     */
66
+    private $loader;
67 67
 
68
-	/**
69
-	 * Specified whether the storage is invalid after failing to
70
-	 * instantiate it.
71
-	 *
72
-	 * @var bool
73
-	 */
74
-	private $invalidStorage = false;
68
+    /**
69
+     * Specified whether the storage is invalid after failing to
70
+     * instantiate it.
71
+     *
72
+     * @var bool
73
+     */
74
+    private $invalidStorage = false;
75 75
 
76
-	/** @var int|null */
77
-	protected $mountId;
76
+    /** @var int|null */
77
+    protected $mountId;
78 78
 
79
-	/**
80
-	 * @param string|\OC\Files\Storage\Storage $storage
81
-	 * @param string $mountpoint
82
-	 * @param array $arguments (optional) configuration for the storage backend
83
-	 * @param \OCP\Files\Storage\IStorageFactory $loader
84
-	 * @param array $mountOptions mount specific options
85
-	 * @param int|null $mountId
86
-	 * @throws \Exception
87
-	 */
88
-	public function __construct($storage, $mountpoint, $arguments = null, $loader = null, $mountOptions = null, $mountId = null) {
89
-		if (is_null($arguments)) {
90
-			$arguments = [];
91
-		}
92
-		if (is_null($loader)) {
93
-			$this->loader = new StorageFactory();
94
-		} else {
95
-			$this->loader = $loader;
96
-		}
79
+    /**
80
+     * @param string|\OC\Files\Storage\Storage $storage
81
+     * @param string $mountpoint
82
+     * @param array $arguments (optional) configuration for the storage backend
83
+     * @param \OCP\Files\Storage\IStorageFactory $loader
84
+     * @param array $mountOptions mount specific options
85
+     * @param int|null $mountId
86
+     * @throws \Exception
87
+     */
88
+    public function __construct($storage, $mountpoint, $arguments = null, $loader = null, $mountOptions = null, $mountId = null) {
89
+        if (is_null($arguments)) {
90
+            $arguments = [];
91
+        }
92
+        if (is_null($loader)) {
93
+            $this->loader = new StorageFactory();
94
+        } else {
95
+            $this->loader = $loader;
96
+        }
97 97
 
98
-		if (!is_null($mountOptions)) {
99
-			$this->mountOptions = $mountOptions;
100
-		}
98
+        if (!is_null($mountOptions)) {
99
+            $this->mountOptions = $mountOptions;
100
+        }
101 101
 
102
-		$mountpoint = $this->formatPath($mountpoint);
103
-		$this->mountPoint = $mountpoint;
104
-		$this->mountId = $mountId;
105
-		if ($storage instanceof Storage) {
106
-			$this->class = get_class($storage);
107
-			$this->storage = $this->loader->wrap($this, $storage);
108
-		} else {
109
-			// Update old classes to new namespace
110
-			if (strpos($storage, 'OC_Filestorage_') !== false) {
111
-				$storage = '\OC\Files\Storage\\' . substr($storage, 15);
112
-			}
113
-			$this->class = $storage;
114
-			$this->arguments = $arguments;
115
-		}
116
-	}
102
+        $mountpoint = $this->formatPath($mountpoint);
103
+        $this->mountPoint = $mountpoint;
104
+        $this->mountId = $mountId;
105
+        if ($storage instanceof Storage) {
106
+            $this->class = get_class($storage);
107
+            $this->storage = $this->loader->wrap($this, $storage);
108
+        } else {
109
+            // Update old classes to new namespace
110
+            if (strpos($storage, 'OC_Filestorage_') !== false) {
111
+                $storage = '\OC\Files\Storage\\' . substr($storage, 15);
112
+            }
113
+            $this->class = $storage;
114
+            $this->arguments = $arguments;
115
+        }
116
+    }
117 117
 
118
-	/**
119
-	 * get complete path to the mount point, relative to data/
120
-	 *
121
-	 * @return string
122
-	 */
123
-	public function getMountPoint() {
124
-		return $this->mountPoint;
125
-	}
118
+    /**
119
+     * get complete path to the mount point, relative to data/
120
+     *
121
+     * @return string
122
+     */
123
+    public function getMountPoint() {
124
+        return $this->mountPoint;
125
+    }
126 126
 
127
-	/**
128
-	 * Sets the mount point path, relative to data/
129
-	 *
130
-	 * @param string $mountPoint new mount point
131
-	 */
132
-	public function setMountPoint($mountPoint) {
133
-		$this->mountPoint = $this->formatPath($mountPoint);
134
-	}
127
+    /**
128
+     * Sets the mount point path, relative to data/
129
+     *
130
+     * @param string $mountPoint new mount point
131
+     */
132
+    public function setMountPoint($mountPoint) {
133
+        $this->mountPoint = $this->formatPath($mountPoint);
134
+    }
135 135
 
136
-	/**
137
-	 * create the storage that is mounted
138
-	 */
139
-	private function createStorage() {
140
-		if ($this->invalidStorage) {
141
-			return;
142
-		}
136
+    /**
137
+     * create the storage that is mounted
138
+     */
139
+    private function createStorage() {
140
+        if ($this->invalidStorage) {
141
+            return;
142
+        }
143 143
 
144
-		if (class_exists($this->class)) {
145
-			try {
146
-				$class = $this->class;
147
-				// prevent recursion by setting the storage before applying wrappers
148
-				$this->storage = new $class($this->arguments);
149
-				$this->storage = $this->loader->wrap($this, $this->storage);
150
-			} catch (\Exception $exception) {
151
-				$this->storage = null;
152
-				$this->invalidStorage = true;
153
-				if ($this->mountPoint === '/') {
154
-					// the root storage could not be initialized, show the user!
155
-					throw new \Exception('The root storage could not be initialized. Please contact your local administrator.', $exception->getCode(), $exception);
156
-				} else {
157
-					\OC::$server->getLogger()->logException($exception, ['level' => ILogger::ERROR]);
158
-				}
159
-				return;
160
-			}
161
-		} else {
162
-			\OCP\Util::writeLog('core', 'storage backend ' . $this->class . ' not found', ILogger::ERROR);
163
-			$this->invalidStorage = true;
164
-			return;
165
-		}
166
-	}
144
+        if (class_exists($this->class)) {
145
+            try {
146
+                $class = $this->class;
147
+                // prevent recursion by setting the storage before applying wrappers
148
+                $this->storage = new $class($this->arguments);
149
+                $this->storage = $this->loader->wrap($this, $this->storage);
150
+            } catch (\Exception $exception) {
151
+                $this->storage = null;
152
+                $this->invalidStorage = true;
153
+                if ($this->mountPoint === '/') {
154
+                    // the root storage could not be initialized, show the user!
155
+                    throw new \Exception('The root storage could not be initialized. Please contact your local administrator.', $exception->getCode(), $exception);
156
+                } else {
157
+                    \OC::$server->getLogger()->logException($exception, ['level' => ILogger::ERROR]);
158
+                }
159
+                return;
160
+            }
161
+        } else {
162
+            \OCP\Util::writeLog('core', 'storage backend ' . $this->class . ' not found', ILogger::ERROR);
163
+            $this->invalidStorage = true;
164
+            return;
165
+        }
166
+    }
167 167
 
168
-	/**
169
-	 * @return \OC\Files\Storage\Storage|null
170
-	 */
171
-	public function getStorage() {
172
-		if (is_null($this->storage)) {
173
-			$this->createStorage();
174
-		}
175
-		return $this->storage;
176
-	}
168
+    /**
169
+     * @return \OC\Files\Storage\Storage|null
170
+     */
171
+    public function getStorage() {
172
+        if (is_null($this->storage)) {
173
+            $this->createStorage();
174
+        }
175
+        return $this->storage;
176
+    }
177 177
 
178
-	/**
179
-	 * @return string
180
-	 */
181
-	public function getStorageId() {
182
-		if (!$this->storageId) {
183
-			if (is_null($this->storage)) {
184
-				$storage = $this->createStorage(); //FIXME: start using exceptions
185
-				if (is_null($storage)) {
186
-					return null;
187
-				}
178
+    /**
179
+     * @return string
180
+     */
181
+    public function getStorageId() {
182
+        if (!$this->storageId) {
183
+            if (is_null($this->storage)) {
184
+                $storage = $this->createStorage(); //FIXME: start using exceptions
185
+                if (is_null($storage)) {
186
+                    return null;
187
+                }
188 188
 
189
-				$this->storage = $storage;
190
-			}
191
-			$this->storageId = $this->storage->getId();
192
-			if (strlen($this->storageId) > 64) {
193
-				$this->storageId = md5($this->storageId);
194
-			}
195
-		}
196
-		return $this->storageId;
197
-	}
189
+                $this->storage = $storage;
190
+            }
191
+            $this->storageId = $this->storage->getId();
192
+            if (strlen($this->storageId) > 64) {
193
+                $this->storageId = md5($this->storageId);
194
+            }
195
+        }
196
+        return $this->storageId;
197
+    }
198 198
 
199
-	/**
200
-	 * @return int
201
-	 */
202
-	public function getNumericStorageId() {
203
-		return $this->getStorage()->getStorageCache()->getNumericId();
204
-	}
199
+    /**
200
+     * @return int
201
+     */
202
+    public function getNumericStorageId() {
203
+        return $this->getStorage()->getStorageCache()->getNumericId();
204
+    }
205 205
 
206
-	/**
207
-	 * @param string $path
208
-	 * @return string
209
-	 */
210
-	public function getInternalPath($path) {
211
-		$path = Filesystem::normalizePath($path, true, false, true);
212
-		if ($this->mountPoint === $path or $this->mountPoint . '/' === $path) {
213
-			$internalPath = '';
214
-		} else {
215
-			$internalPath = substr($path, strlen($this->mountPoint));
216
-		}
217
-		// substr returns false instead of an empty string, we always want a string
218
-		return (string)$internalPath;
219
-	}
206
+    /**
207
+     * @param string $path
208
+     * @return string
209
+     */
210
+    public function getInternalPath($path) {
211
+        $path = Filesystem::normalizePath($path, true, false, true);
212
+        if ($this->mountPoint === $path or $this->mountPoint . '/' === $path) {
213
+            $internalPath = '';
214
+        } else {
215
+            $internalPath = substr($path, strlen($this->mountPoint));
216
+        }
217
+        // substr returns false instead of an empty string, we always want a string
218
+        return (string)$internalPath;
219
+    }
220 220
 
221
-	/**
222
-	 * @param string $path
223
-	 * @return string
224
-	 */
225
-	private function formatPath($path) {
226
-		$path = Filesystem::normalizePath($path);
227
-		if (strlen($path) > 1) {
228
-			$path .= '/';
229
-		}
230
-		return $path;
231
-	}
221
+    /**
222
+     * @param string $path
223
+     * @return string
224
+     */
225
+    private function formatPath($path) {
226
+        $path = Filesystem::normalizePath($path);
227
+        if (strlen($path) > 1) {
228
+            $path .= '/';
229
+        }
230
+        return $path;
231
+    }
232 232
 
233
-	/**
234
-	 * @param callable $wrapper
235
-	 */
236
-	public function wrapStorage($wrapper) {
237
-		$storage = $this->getStorage();
238
-		// storage can be null if it couldn't be initialized
239
-		if ($storage != null) {
240
-			$this->storage = $wrapper($this->mountPoint, $storage, $this);
241
-		}
242
-	}
233
+    /**
234
+     * @param callable $wrapper
235
+     */
236
+    public function wrapStorage($wrapper) {
237
+        $storage = $this->getStorage();
238
+        // storage can be null if it couldn't be initialized
239
+        if ($storage != null) {
240
+            $this->storage = $wrapper($this->mountPoint, $storage, $this);
241
+        }
242
+    }
243 243
 
244
-	/**
245
-	 * Get a mount option
246
-	 *
247
-	 * @param string $name Name of the mount option to get
248
-	 * @param mixed $default Default value for the mount option
249
-	 * @return mixed
250
-	 */
251
-	public function getOption($name, $default) {
252
-		return isset($this->mountOptions[$name]) ? $this->mountOptions[$name] : $default;
253
-	}
244
+    /**
245
+     * Get a mount option
246
+     *
247
+     * @param string $name Name of the mount option to get
248
+     * @param mixed $default Default value for the mount option
249
+     * @return mixed
250
+     */
251
+    public function getOption($name, $default) {
252
+        return isset($this->mountOptions[$name]) ? $this->mountOptions[$name] : $default;
253
+    }
254 254
 
255
-	/**
256
-	 * Get all options for the mount
257
-	 *
258
-	 * @return array
259
-	 */
260
-	public function getOptions() {
261
-		return $this->mountOptions;
262
-	}
255
+    /**
256
+     * Get all options for the mount
257
+     *
258
+     * @return array
259
+     */
260
+    public function getOptions() {
261
+        return $this->mountOptions;
262
+    }
263 263
 
264
-	/**
265
-	 * Get the file id of the root of the storage
266
-	 *
267
-	 * @return int
268
-	 */
269
-	public function getStorageRootId() {
270
-		if (is_null($this->rootId) || $this->rootId === -1) {
271
-			$storage = $this->getStorage();
272
-			// if we can't create the storage return -1 as root id, this is then handled the same as if the root isn't scanned yet
273
-			if ($storage === null) {
274
-				$this->rootId = -1;
275
-			} else {
276
-				$this->rootId = (int)$storage->getCache()->getId('');
277
-			}
278
-		}
279
-		return $this->rootId;
280
-	}
264
+    /**
265
+     * Get the file id of the root of the storage
266
+     *
267
+     * @return int
268
+     */
269
+    public function getStorageRootId() {
270
+        if (is_null($this->rootId) || $this->rootId === -1) {
271
+            $storage = $this->getStorage();
272
+            // if we can't create the storage return -1 as root id, this is then handled the same as if the root isn't scanned yet
273
+            if ($storage === null) {
274
+                $this->rootId = -1;
275
+            } else {
276
+                $this->rootId = (int)$storage->getCache()->getId('');
277
+            }
278
+        }
279
+        return $this->rootId;
280
+    }
281 281
 
282
-	public function getMountId() {
283
-		return $this->mountId;
284
-	}
282
+    public function getMountId() {
283
+        return $this->mountId;
284
+    }
285 285
 
286
-	public function getMountType() {
287
-		return '';
288
-	}
286
+    public function getMountType() {
287
+        return '';
288
+    }
289 289
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		} else {
109 109
 			// Update old classes to new namespace
110 110
 			if (strpos($storage, 'OC_Filestorage_') !== false) {
111
-				$storage = '\OC\Files\Storage\\' . substr($storage, 15);
111
+				$storage = '\OC\Files\Storage\\'.substr($storage, 15);
112 112
 			}
113 113
 			$this->class = $storage;
114 114
 			$this->arguments = $arguments;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 				return;
160 160
 			}
161 161
 		} else {
162
-			\OCP\Util::writeLog('core', 'storage backend ' . $this->class . ' not found', ILogger::ERROR);
162
+			\OCP\Util::writeLog('core', 'storage backend '.$this->class.' not found', ILogger::ERROR);
163 163
 			$this->invalidStorage = true;
164 164
 			return;
165 165
 		}
@@ -209,13 +209,13 @@  discard block
 block discarded – undo
209 209
 	 */
210 210
 	public function getInternalPath($path) {
211 211
 		$path = Filesystem::normalizePath($path, true, false, true);
212
-		if ($this->mountPoint === $path or $this->mountPoint . '/' === $path) {
212
+		if ($this->mountPoint === $path or $this->mountPoint.'/' === $path) {
213 213
 			$internalPath = '';
214 214
 		} else {
215 215
 			$internalPath = substr($path, strlen($this->mountPoint));
216 216
 		}
217 217
 		// substr returns false instead of an empty string, we always want a string
218
-		return (string)$internalPath;
218
+		return (string) $internalPath;
219 219
 	}
220 220
 
221 221
 	/**
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 			if ($storage === null) {
274 274
 				$this->rootId = -1;
275 275
 			} else {
276
-				$this->rootId = (int)$storage->getCache()->getId('');
276
+				$this->rootId = (int) $storage->getCache()->getId('');
277 277
 			}
278 278
 		}
279 279
 		return $this->rootId;
Please login to merge, or discard this patch.