Completed
Pull Request — master (#3233)
by Christoph
14:57
created
apps/dav/lib/Connector/Sabre/ShareTypeList.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -32,61 +32,61 @@
 block discarded – undo
32 32
  * This property contains multiple "share-type" elements, each containing a share type.
33 33
  */
34 34
 class ShareTypeList implements Element {
35
-	const NS_OWNCLOUD = 'http://owncloud.org/ns';
35
+    const NS_OWNCLOUD = 'http://owncloud.org/ns';
36 36
 
37
-	/**
38
-	 * Share types
39
-	 *
40
-	 * @var int[]
41
-	 */
42
-	private $shareTypes;
37
+    /**
38
+     * Share types
39
+     *
40
+     * @var int[]
41
+     */
42
+    private $shareTypes;
43 43
 
44
-	/**
45
-	 * @param int[] $shareTypes
46
-	 */
47
-	public function __construct($shareTypes) {
48
-		$this->shareTypes = $shareTypes;
49
-	}
44
+    /**
45
+     * @param int[] $shareTypes
46
+     */
47
+    public function __construct($shareTypes) {
48
+        $this->shareTypes = $shareTypes;
49
+    }
50 50
 
51
-	/**
52
-	 * Returns the share types
53
-	 *
54
-	 * @return int[]
55
-	 */
56
-	public function getShareTypes() {
57
-		return $this->shareTypes;
58
-	}
51
+    /**
52
+     * Returns the share types
53
+     *
54
+     * @return int[]
55
+     */
56
+    public function getShareTypes() {
57
+        return $this->shareTypes;
58
+    }
59 59
 
60
-	/**
61
-	 * The deserialize method is called during xml parsing.
62
-	 *
63
-	 * @param Reader $reader
64
-	 * @return mixed
65
-	 */
66
-	static function xmlDeserialize(Reader $reader) {
67
-		$shareTypes = [];
60
+    /**
61
+     * The deserialize method is called during xml parsing.
62
+     *
63
+     * @param Reader $reader
64
+     * @return mixed
65
+     */
66
+    static function xmlDeserialize(Reader $reader) {
67
+        $shareTypes = [];
68 68
 
69
-		$tree = $reader->parseInnerTree();
70
-		if ($tree === null) {
71
-			return null;
72
-		}
73
-		foreach ($tree as $elem) {
74
-			if ($elem['name'] === '{' . self::NS_OWNCLOUD . '}share-type') {
75
-				$shareTypes[] = (int)$elem['value'];
76
-			}
77
-		}
78
-		return new self($shareTypes);
79
-	}
69
+        $tree = $reader->parseInnerTree();
70
+        if ($tree === null) {
71
+            return null;
72
+        }
73
+        foreach ($tree as $elem) {
74
+            if ($elem['name'] === '{' . self::NS_OWNCLOUD . '}share-type') {
75
+                $shareTypes[] = (int)$elem['value'];
76
+            }
77
+        }
78
+        return new self($shareTypes);
79
+    }
80 80
 
81
-	/**
82
-	 * The xmlSerialize metod is called during xml writing.
83
-	 *
84
-	 * @param Writer $writer
85
-	 * @return void
86
-	 */
87
-	function xmlSerialize(Writer $writer) {
88
-		foreach ($this->shareTypes as $shareType) {
89
-			$writer->writeElement('{' . self::NS_OWNCLOUD . '}share-type', $shareType);
90
-		}
91
-	}
81
+    /**
82
+     * The xmlSerialize metod is called during xml writing.
83
+     *
84
+     * @param Writer $writer
85
+     * @return void
86
+     */
87
+    function xmlSerialize(Writer $writer) {
88
+        foreach ($this->shareTypes as $shareType) {
89
+            $writer->writeElement('{' . self::NS_OWNCLOUD . '}share-type', $shareType);
90
+        }
91
+    }
92 92
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/LockPlugin.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -34,53 +34,53 @@
 block discarded – undo
34 34
 use Sabre\HTTP\RequestInterface;
35 35
 
36 36
 class LockPlugin extends ServerPlugin {
37
-	/**
38
-	 * Reference to main server object
39
-	 *
40
-	 * @var \Sabre\DAV\Server
41
-	 */
42
-	private $server;
37
+    /**
38
+     * Reference to main server object
39
+     *
40
+     * @var \Sabre\DAV\Server
41
+     */
42
+    private $server;
43 43
 
44
-	/**
45
-	 * {@inheritdoc}
46
-	 */
47
-	public function initialize(\Sabre\DAV\Server $server) {
48
-		$this->server = $server;
49
-		$this->server->on('beforeMethod', [$this, 'getLock'], 50);
50
-		$this->server->on('afterMethod', [$this, 'releaseLock'], 50);
51
-	}
44
+    /**
45
+     * {@inheritdoc}
46
+     */
47
+    public function initialize(\Sabre\DAV\Server $server) {
48
+        $this->server = $server;
49
+        $this->server->on('beforeMethod', [$this, 'getLock'], 50);
50
+        $this->server->on('afterMethod', [$this, 'releaseLock'], 50);
51
+    }
52 52
 
53
-	public function getLock(RequestInterface $request) {
54
-		// we can't listen on 'beforeMethod:PUT' due to order of operations with setting up the tree
55
-		// so instead we limit ourselves to the PUT method manually
56
-		if ($request->getMethod() !== 'PUT' || isset($_SERVER['HTTP_OC_CHUNKED'])) {
57
-			return;
58
-		}
59
-		try {
60
-			$node = $this->server->tree->getNodeForPath($request->getPath());
61
-		} catch (NotFound $e) {
62
-			return;
63
-		}
64
-		if ($node instanceof Node) {
65
-			try {
66
-				$node->acquireLock(ILockingProvider::LOCK_SHARED);
67
-			} catch (LockedException $e) {
68
-				throw new FileLocked($e->getMessage(), $e->getCode(), $e);
69
-			}
70
-		}
71
-	}
53
+    public function getLock(RequestInterface $request) {
54
+        // we can't listen on 'beforeMethod:PUT' due to order of operations with setting up the tree
55
+        // so instead we limit ourselves to the PUT method manually
56
+        if ($request->getMethod() !== 'PUT' || isset($_SERVER['HTTP_OC_CHUNKED'])) {
57
+            return;
58
+        }
59
+        try {
60
+            $node = $this->server->tree->getNodeForPath($request->getPath());
61
+        } catch (NotFound $e) {
62
+            return;
63
+        }
64
+        if ($node instanceof Node) {
65
+            try {
66
+                $node->acquireLock(ILockingProvider::LOCK_SHARED);
67
+            } catch (LockedException $e) {
68
+                throw new FileLocked($e->getMessage(), $e->getCode(), $e);
69
+            }
70
+        }
71
+    }
72 72
 
73
-	public function releaseLock(RequestInterface $request) {
74
-		if ($request->getMethod() !== 'PUT' || isset($_SERVER['HTTP_OC_CHUNKED'])) {
75
-			return;
76
-		}
77
-		try {
78
-			$node = $this->server->tree->getNodeForPath($request->getPath());
79
-		} catch (NotFound $e) {
80
-			return;
81
-		}
82
-		if ($node instanceof Node) {
83
-			$node->releaseLock(ILockingProvider::LOCK_SHARED);
84
-		}
85
-	}
73
+    public function releaseLock(RequestInterface $request) {
74
+        if ($request->getMethod() !== 'PUT' || isset($_SERVER['HTTP_OC_CHUNKED'])) {
75
+            return;
76
+        }
77
+        try {
78
+            $node = $this->server->tree->getNodeForPath($request->getPath());
79
+        } catch (NotFound $e) {
80
+            return;
81
+        }
82
+        if ($node instanceof Node) {
83
+            $node->releaseLock(ILockingProvider::LOCK_SHARED);
84
+        }
85
+    }
86 86
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/File.php 1 patch
Indentation   +507 added lines, -507 removed lines patch added patch discarded remove patch
@@ -57,512 +57,512 @@
 block discarded – undo
57 57
 
58 58
 class File extends Node implements IFile {
59 59
 
60
-	/**
61
-	 * Updates the data
62
-	 *
63
-	 * The data argument is a readable stream resource.
64
-	 *
65
-	 * After a successful put operation, you may choose to return an ETag. The
66
-	 * etag must always be surrounded by double-quotes. These quotes must
67
-	 * appear in the actual string you're returning.
68
-	 *
69
-	 * Clients may use the ETag from a PUT request to later on make sure that
70
-	 * when they update the file, the contents haven't changed in the mean
71
-	 * time.
72
-	 *
73
-	 * If you don't plan to store the file byte-by-byte, and you return a
74
-	 * different object on a subsequent GET you are strongly recommended to not
75
-	 * return an ETag, and just return null.
76
-	 *
77
-	 * @param resource $data
78
-	 *
79
-	 * @throws Forbidden
80
-	 * @throws UnsupportedMediaType
81
-	 * @throws BadRequest
82
-	 * @throws Exception
83
-	 * @throws EntityTooLarge
84
-	 * @throws ServiceUnavailable
85
-	 * @throws FileLocked
86
-	 * @return string|null
87
-	 */
88
-	public function put($data) {
89
-		try {
90
-			$exists = $this->fileView->file_exists($this->path);
91
-			if ($this->info && $exists && !$this->info->isUpdateable()) {
92
-				throw new Forbidden();
93
-			}
94
-		} catch (StorageNotAvailableException $e) {
95
-			throw new ServiceUnavailable("File is not updatable: " . $e->getMessage());
96
-		}
97
-
98
-		// verify path of the target
99
-		$this->verifyPath();
100
-
101
-		// chunked handling
102
-		if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
103
-			try {
104
-				return $this->createFileChunked($data);
105
-			} catch (\Exception $e) {
106
-				$this->convertToSabreException($e);
107
-			}
108
-		}
109
-
110
-		list($partStorage) = $this->fileView->resolvePath($this->path);
111
-		$needsPartFile = $this->needsPartFile($partStorage) && (strlen($this->path) > 1);
112
-
113
-		if ($needsPartFile) {
114
-			// mark file as partial while uploading (ignored by the scanner)
115
-			$partFilePath = $this->getPartFileBasePath($this->path) . '.ocTransferId' . rand() . '.part';
116
-		} else {
117
-			// upload file directly as the final path
118
-			$partFilePath = $this->path;
119
-		}
120
-
121
-		// the part file and target file might be on a different storage in case of a single file storage (e.g. single file share)
122
-		/** @var \OC\Files\Storage\Storage $partStorage */
123
-		list($partStorage, $internalPartPath) = $this->fileView->resolvePath($partFilePath);
124
-		/** @var \OC\Files\Storage\Storage $storage */
125
-		list($storage, $internalPath) = $this->fileView->resolvePath($this->path);
126
-		try {
127
-			$target = $partStorage->fopen($internalPartPath, 'wb');
128
-			if ($target === false) {
129
-				\OCP\Util::writeLog('webdav', '\OC\Files\Filesystem::fopen() failed', \OCP\Util::ERROR);
130
-				// because we have no clue about the cause we can only throw back a 500/Internal Server Error
131
-				throw new Exception('Could not write file contents');
132
-			}
133
-			list($count, $result) = \OC_Helper::streamCopy($data, $target);
134
-			fclose($target);
135
-
136
-			if ($result === false) {
137
-				$expected = -1;
138
-				if (isset($_SERVER['CONTENT_LENGTH'])) {
139
-					$expected = $_SERVER['CONTENT_LENGTH'];
140
-				}
141
-				throw new Exception('Error while copying file to target location (copied bytes: ' . $count . ', expected filesize: ' . $expected . ' )');
142
-			}
143
-
144
-			// if content length is sent by client:
145
-			// double check if the file was fully received
146
-			// compare expected and actual size
147
-			if (isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['REQUEST_METHOD'] === 'PUT') {
148
-				$expected = $_SERVER['CONTENT_LENGTH'];
149
-				if ($count != $expected) {
150
-					throw new BadRequest('expected filesize ' . $expected . ' got ' . $count);
151
-				}
152
-			}
153
-
154
-		} catch (\Exception $e) {
155
-			if ($needsPartFile) {
156
-				$partStorage->unlink($internalPartPath);
157
-			}
158
-			$this->convertToSabreException($e);
159
-		}
160
-
161
-		try {
162
-			$view = \OC\Files\Filesystem::getView();
163
-			if ($view) {
164
-				$run = $this->emitPreHooks($exists);
165
-			} else {
166
-				$run = true;
167
-			}
168
-
169
-			try {
170
-				$this->changeLock(ILockingProvider::LOCK_EXCLUSIVE);
171
-			} catch (LockedException $e) {
172
-				if ($needsPartFile) {
173
-					$partStorage->unlink($internalPartPath);
174
-				}
175
-				throw new FileLocked($e->getMessage(), $e->getCode(), $e);
176
-			}
177
-
178
-			if ($needsPartFile) {
179
-				// rename to correct path
180
-				try {
181
-					if ($run) {
182
-						$renameOkay = $storage->moveFromStorage($partStorage, $internalPartPath, $internalPath);
183
-						$fileExists = $storage->file_exists($internalPath);
184
-					}
185
-					if (!$run || $renameOkay === false || $fileExists === false) {
186
-						\OCP\Util::writeLog('webdav', 'renaming part file to final file failed', \OCP\Util::ERROR);
187
-						throw new Exception('Could not rename part file to final file');
188
-					}
189
-				} catch (ForbiddenException $ex) {
190
-					throw new DAVForbiddenException($ex->getMessage(), $ex->getRetry());
191
-				} catch (\Exception $e) {
192
-					$partStorage->unlink($internalPartPath);
193
-					$this->convertToSabreException($e);
194
-				}
195
-			}
196
-
197
-			// since we skipped the view we need to scan and emit the hooks ourselves
198
-			$storage->getUpdater()->update($internalPath);
199
-
200
-			try {
201
-				$this->changeLock(ILockingProvider::LOCK_SHARED);
202
-			} catch (LockedException $e) {
203
-				throw new FileLocked($e->getMessage(), $e->getCode(), $e);
204
-			}
205
-
206
-			// allow sync clients to send the mtime along in a header
207
-			$request = \OC::$server->getRequest();
208
-			if (isset($request->server['HTTP_X_OC_MTIME'])) {
209
-				if ($this->fileView->touch($this->path, $request->server['HTTP_X_OC_MTIME'])) {
210
-					header('X-OC-MTime: accepted');
211
-				}
212
-			}
60
+    /**
61
+     * Updates the data
62
+     *
63
+     * The data argument is a readable stream resource.
64
+     *
65
+     * After a successful put operation, you may choose to return an ETag. The
66
+     * etag must always be surrounded by double-quotes. These quotes must
67
+     * appear in the actual string you're returning.
68
+     *
69
+     * Clients may use the ETag from a PUT request to later on make sure that
70
+     * when they update the file, the contents haven't changed in the mean
71
+     * time.
72
+     *
73
+     * If you don't plan to store the file byte-by-byte, and you return a
74
+     * different object on a subsequent GET you are strongly recommended to not
75
+     * return an ETag, and just return null.
76
+     *
77
+     * @param resource $data
78
+     *
79
+     * @throws Forbidden
80
+     * @throws UnsupportedMediaType
81
+     * @throws BadRequest
82
+     * @throws Exception
83
+     * @throws EntityTooLarge
84
+     * @throws ServiceUnavailable
85
+     * @throws FileLocked
86
+     * @return string|null
87
+     */
88
+    public function put($data) {
89
+        try {
90
+            $exists = $this->fileView->file_exists($this->path);
91
+            if ($this->info && $exists && !$this->info->isUpdateable()) {
92
+                throw new Forbidden();
93
+            }
94
+        } catch (StorageNotAvailableException $e) {
95
+            throw new ServiceUnavailable("File is not updatable: " . $e->getMessage());
96
+        }
97
+
98
+        // verify path of the target
99
+        $this->verifyPath();
100
+
101
+        // chunked handling
102
+        if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
103
+            try {
104
+                return $this->createFileChunked($data);
105
+            } catch (\Exception $e) {
106
+                $this->convertToSabreException($e);
107
+            }
108
+        }
109
+
110
+        list($partStorage) = $this->fileView->resolvePath($this->path);
111
+        $needsPartFile = $this->needsPartFile($partStorage) && (strlen($this->path) > 1);
112
+
113
+        if ($needsPartFile) {
114
+            // mark file as partial while uploading (ignored by the scanner)
115
+            $partFilePath = $this->getPartFileBasePath($this->path) . '.ocTransferId' . rand() . '.part';
116
+        } else {
117
+            // upload file directly as the final path
118
+            $partFilePath = $this->path;
119
+        }
120
+
121
+        // the part file and target file might be on a different storage in case of a single file storage (e.g. single file share)
122
+        /** @var \OC\Files\Storage\Storage $partStorage */
123
+        list($partStorage, $internalPartPath) = $this->fileView->resolvePath($partFilePath);
124
+        /** @var \OC\Files\Storage\Storage $storage */
125
+        list($storage, $internalPath) = $this->fileView->resolvePath($this->path);
126
+        try {
127
+            $target = $partStorage->fopen($internalPartPath, 'wb');
128
+            if ($target === false) {
129
+                \OCP\Util::writeLog('webdav', '\OC\Files\Filesystem::fopen() failed', \OCP\Util::ERROR);
130
+                // because we have no clue about the cause we can only throw back a 500/Internal Server Error
131
+                throw new Exception('Could not write file contents');
132
+            }
133
+            list($count, $result) = \OC_Helper::streamCopy($data, $target);
134
+            fclose($target);
135
+
136
+            if ($result === false) {
137
+                $expected = -1;
138
+                if (isset($_SERVER['CONTENT_LENGTH'])) {
139
+                    $expected = $_SERVER['CONTENT_LENGTH'];
140
+                }
141
+                throw new Exception('Error while copying file to target location (copied bytes: ' . $count . ', expected filesize: ' . $expected . ' )');
142
+            }
143
+
144
+            // if content length is sent by client:
145
+            // double check if the file was fully received
146
+            // compare expected and actual size
147
+            if (isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['REQUEST_METHOD'] === 'PUT') {
148
+                $expected = $_SERVER['CONTENT_LENGTH'];
149
+                if ($count != $expected) {
150
+                    throw new BadRequest('expected filesize ' . $expected . ' got ' . $count);
151
+                }
152
+            }
153
+
154
+        } catch (\Exception $e) {
155
+            if ($needsPartFile) {
156
+                $partStorage->unlink($internalPartPath);
157
+            }
158
+            $this->convertToSabreException($e);
159
+        }
160
+
161
+        try {
162
+            $view = \OC\Files\Filesystem::getView();
163
+            if ($view) {
164
+                $run = $this->emitPreHooks($exists);
165
+            } else {
166
+                $run = true;
167
+            }
168
+
169
+            try {
170
+                $this->changeLock(ILockingProvider::LOCK_EXCLUSIVE);
171
+            } catch (LockedException $e) {
172
+                if ($needsPartFile) {
173
+                    $partStorage->unlink($internalPartPath);
174
+                }
175
+                throw new FileLocked($e->getMessage(), $e->getCode(), $e);
176
+            }
177
+
178
+            if ($needsPartFile) {
179
+                // rename to correct path
180
+                try {
181
+                    if ($run) {
182
+                        $renameOkay = $storage->moveFromStorage($partStorage, $internalPartPath, $internalPath);
183
+                        $fileExists = $storage->file_exists($internalPath);
184
+                    }
185
+                    if (!$run || $renameOkay === false || $fileExists === false) {
186
+                        \OCP\Util::writeLog('webdav', 'renaming part file to final file failed', \OCP\Util::ERROR);
187
+                        throw new Exception('Could not rename part file to final file');
188
+                    }
189
+                } catch (ForbiddenException $ex) {
190
+                    throw new DAVForbiddenException($ex->getMessage(), $ex->getRetry());
191
+                } catch (\Exception $e) {
192
+                    $partStorage->unlink($internalPartPath);
193
+                    $this->convertToSabreException($e);
194
+                }
195
+            }
196
+
197
+            // since we skipped the view we need to scan and emit the hooks ourselves
198
+            $storage->getUpdater()->update($internalPath);
199
+
200
+            try {
201
+                $this->changeLock(ILockingProvider::LOCK_SHARED);
202
+            } catch (LockedException $e) {
203
+                throw new FileLocked($e->getMessage(), $e->getCode(), $e);
204
+            }
205
+
206
+            // allow sync clients to send the mtime along in a header
207
+            $request = \OC::$server->getRequest();
208
+            if (isset($request->server['HTTP_X_OC_MTIME'])) {
209
+                if ($this->fileView->touch($this->path, $request->server['HTTP_X_OC_MTIME'])) {
210
+                    header('X-OC-MTime: accepted');
211
+                }
212
+            }
213 213
 					
214
-			if ($view) {
215
-				$this->emitPostHooks($exists);
216
-			}
217
-
218
-			$this->refreshInfo();
219
-
220
-			if (isset($request->server['HTTP_OC_CHECKSUM'])) {
221
-				$checksum = trim($request->server['HTTP_OC_CHECKSUM']);
222
-				$this->fileView->putFileInfo($this->path, ['checksum' => $checksum]);
223
-				$this->refreshInfo();
224
-			} else if ($this->getChecksum() !== null && $this->getChecksum() !== '') {
225
-				$this->fileView->putFileInfo($this->path, ['checksum' => '']);
226
-				$this->refreshInfo();
227
-			}
228
-
229
-		} catch (StorageNotAvailableException $e) {
230
-			throw new ServiceUnavailable("Failed to check file size: " . $e->getMessage());
231
-		}
232
-
233
-		return '"' . $this->info->getEtag() . '"';
234
-	}
235
-
236
-	private function getPartFileBasePath($path) {
237
-		$partFileInStorage = \OC::$server->getConfig()->getSystemValue('part_file_in_storage', true);
238
-		if ($partFileInStorage) {
239
-			return $path;
240
-		} else {
241
-			return md5($path); // will place it in the root of the view with a unique name
242
-		}
243
-	}
244
-
245
-	/**
246
-	 * @param string $path
247
-	 */
248
-	private function emitPreHooks($exists, $path = null) {
249
-		if (is_null($path)) {
250
-			$path = $this->path;
251
-		}
252
-		$hookPath = Filesystem::getView()->getRelativePath($this->fileView->getAbsolutePath($path));
253
-		$run = true;
254
-
255
-		if (!$exists) {
256
-			\OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_create, array(
257
-				\OC\Files\Filesystem::signal_param_path => $hookPath,
258
-				\OC\Files\Filesystem::signal_param_run => &$run,
259
-			));
260
-		} else {
261
-			\OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_update, array(
262
-				\OC\Files\Filesystem::signal_param_path => $hookPath,
263
-				\OC\Files\Filesystem::signal_param_run => &$run,
264
-			));
265
-		}
266
-		\OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_write, array(
267
-			\OC\Files\Filesystem::signal_param_path => $hookPath,
268
-			\OC\Files\Filesystem::signal_param_run => &$run,
269
-		));
270
-		return $run;
271
-	}
272
-
273
-	/**
274
-	 * @param string $path
275
-	 */
276
-	private function emitPostHooks($exists, $path = null) {
277
-		if (is_null($path)) {
278
-			$path = $this->path;
279
-		}
280
-		$hookPath = Filesystem::getView()->getRelativePath($this->fileView->getAbsolutePath($path));
281
-		if (!$exists) {
282
-			\OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_create, array(
283
-				\OC\Files\Filesystem::signal_param_path => $hookPath
284
-			));
285
-		} else {
286
-			\OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_update, array(
287
-				\OC\Files\Filesystem::signal_param_path => $hookPath
288
-			));
289
-		}
290
-		\OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_write, array(
291
-			\OC\Files\Filesystem::signal_param_path => $hookPath
292
-		));
293
-	}
294
-
295
-	/**
296
-	 * Returns the data
297
-	 *
298
-	 * @return resource
299
-	 * @throws Forbidden
300
-	 * @throws ServiceUnavailable
301
-	 */
302
-	public function get() {
303
-		//throw exception if encryption is disabled but files are still encrypted
304
-		try {
305
-			$res = $this->fileView->fopen(ltrim($this->path, '/'), 'rb');
306
-			if ($res === false) {
307
-				throw new ServiceUnavailable("Could not open file");
308
-			}
309
-			return $res;
310
-		} catch (GenericEncryptionException $e) {
311
-			// returning 503 will allow retry of the operation at a later point in time
312
-			throw new ServiceUnavailable("Encryption not ready: " . $e->getMessage());
313
-		} catch (StorageNotAvailableException $e) {
314
-			throw new ServiceUnavailable("Failed to open file: " . $e->getMessage());
315
-		} catch (ForbiddenException $ex) {
316
-			throw new DAVForbiddenException($ex->getMessage(), $ex->getRetry());
317
-		} catch (LockedException $e) {
318
-			throw new FileLocked($e->getMessage(), $e->getCode(), $e);
319
-		}
320
-	}
321
-
322
-	/**
323
-	 * Delete the current file
324
-	 *
325
-	 * @throws Forbidden
326
-	 * @throws ServiceUnavailable
327
-	 */
328
-	public function delete() {
329
-		if (!$this->info->isDeletable()) {
330
-			throw new Forbidden();
331
-		}
332
-
333
-		try {
334
-			if (!$this->fileView->unlink($this->path)) {
335
-				// assume it wasn't possible to delete due to permissions
336
-				throw new Forbidden();
337
-			}
338
-		} catch (StorageNotAvailableException $e) {
339
-			throw new ServiceUnavailable("Failed to unlink: " . $e->getMessage());
340
-		} catch (ForbiddenException $ex) {
341
-			throw new DAVForbiddenException($ex->getMessage(), $ex->getRetry());
342
-		} catch (LockedException $e) {
343
-			throw new FileLocked($e->getMessage(), $e->getCode(), $e);
344
-		}
345
-	}
346
-
347
-	/**
348
-	 * Returns the mime-type for a file
349
-	 *
350
-	 * If null is returned, we'll assume application/octet-stream
351
-	 *
352
-	 * @return string
353
-	 */
354
-	public function getContentType() {
355
-		$mimeType = $this->info->getMimetype();
356
-
357
-		// PROPFIND needs to return the correct mime type, for consistency with the web UI
358
-		if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PROPFIND') {
359
-			return $mimeType;
360
-		}
361
-		return \OC::$server->getMimeTypeDetector()->getSecureMimeType($mimeType);
362
-	}
363
-
364
-	/**
365
-	 * @return array|false
366
-	 */
367
-	public function getDirectDownload() {
368
-		if (\OCP\App::isEnabled('encryption')) {
369
-			return [];
370
-		}
371
-		/** @var \OCP\Files\Storage $storage */
372
-		list($storage, $internalPath) = $this->fileView->resolvePath($this->path);
373
-		if (is_null($storage)) {
374
-			return [];
375
-		}
376
-
377
-		return $storage->getDirectDownload($internalPath);
378
-	}
379
-
380
-	/**
381
-	 * @param resource $data
382
-	 * @return null|string
383
-	 * @throws Exception
384
-	 * @throws BadRequest
385
-	 * @throws NotImplemented
386
-	 * @throws ServiceUnavailable
387
-	 */
388
-	private function createFileChunked($data) {
389
-		list($path, $name) = \Sabre\HTTP\URLUtil::splitPath($this->path);
390
-
391
-		$info = \OC_FileChunking::decodeName($name);
392
-		if (empty($info)) {
393
-			throw new NotImplemented('Invalid chunk name');
394
-		}
395
-
396
-		$chunk_handler = new \OC_FileChunking($info);
397
-		$bytesWritten = $chunk_handler->store($info['index'], $data);
398
-
399
-		//detect aborted upload
400
-		if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT') {
401
-			if (isset($_SERVER['CONTENT_LENGTH'])) {
402
-				$expected = $_SERVER['CONTENT_LENGTH'];
403
-				if ($bytesWritten != $expected) {
404
-					$chunk_handler->remove($info['index']);
405
-					throw new BadRequest(
406
-						'expected filesize ' . $expected . ' got ' . $bytesWritten);
407
-				}
408
-			}
409
-		}
410
-
411
-		if ($chunk_handler->isComplete()) {
412
-			list($storage,) = $this->fileView->resolvePath($path);
413
-			$needsPartFile = $this->needsPartFile($storage);
414
-			$partFile = null;
415
-
416
-			$targetPath = $path . '/' . $info['name'];
417
-			/** @var \OC\Files\Storage\Storage $targetStorage */
418
-			list($targetStorage, $targetInternalPath) = $this->fileView->resolvePath($targetPath);
419
-
420
-			$exists = $this->fileView->file_exists($targetPath);
421
-
422
-			try {
423
-				$this->fileView->lockFile($targetPath, ILockingProvider::LOCK_SHARED);
424
-
425
-				$this->emitPreHooks($exists, $targetPath);
426
-				$this->fileView->changeLock($targetPath, ILockingProvider::LOCK_EXCLUSIVE);
427
-				/** @var \OC\Files\Storage\Storage $targetStorage */
428
-				list($targetStorage, $targetInternalPath) = $this->fileView->resolvePath($targetPath);
429
-
430
-				if ($needsPartFile) {
431
-					// we first assembly the target file as a part file
432
-					$partFile = $this->getPartFileBasePath($path . '/' . $info['name']) . '.ocTransferId' . $info['transferid'] . '.part';
433
-					/** @var \OC\Files\Storage\Storage $targetStorage */
434
-					list($partStorage, $partInternalPath) = $this->fileView->resolvePath($partFile);
435
-
436
-
437
-					$chunk_handler->file_assemble($partStorage, $partInternalPath);
438
-
439
-					// here is the final atomic rename
440
-					$renameOkay = $targetStorage->moveFromStorage($partStorage, $partInternalPath, $targetInternalPath);
441
-					$fileExists = $targetStorage->file_exists($targetInternalPath);
442
-					if ($renameOkay === false || $fileExists === false) {
443
-						\OCP\Util::writeLog('webdav', '\OC\Files\Filesystem::rename() failed', \OCP\Util::ERROR);
444
-						// only delete if an error occurred and the target file was already created
445
-						if ($fileExists) {
446
-							// set to null to avoid double-deletion when handling exception
447
-							// stray part file
448
-							$partFile = null;
449
-							$targetStorage->unlink($targetInternalPath);
450
-						}
451
-						$this->fileView->changeLock($targetPath, ILockingProvider::LOCK_SHARED);
452
-						throw new Exception('Could not rename part file assembled from chunks');
453
-					}
454
-				} else {
455
-					// assemble directly into the final file
456
-					$chunk_handler->file_assemble($targetStorage, $targetInternalPath);
457
-				}
458
-
459
-				// allow sync clients to send the mtime along in a header
460
-				$request = \OC::$server->getRequest();
461
-				if (isset($request->server['HTTP_X_OC_MTIME'])) {
462
-					if ($targetStorage->touch($targetInternalPath, $request->server['HTTP_X_OC_MTIME'])) {
463
-						header('X-OC-MTime: accepted');
464
-					}
465
-				}
466
-
467
-				// since we skipped the view we need to scan and emit the hooks ourselves
468
-				$targetStorage->getUpdater()->update($targetInternalPath);
469
-
470
-				$this->fileView->changeLock($targetPath, ILockingProvider::LOCK_SHARED);
471
-
472
-				$this->emitPostHooks($exists, $targetPath);
473
-
474
-				// FIXME: should call refreshInfo but can't because $this->path is not the of the final file
475
-				$info = $this->fileView->getFileInfo($targetPath);
476
-
477
-				if (isset($request->server['HTTP_OC_CHECKSUM'])) {
478
-					$checksum = trim($request->server['HTTP_OC_CHECKSUM']);
479
-					$this->fileView->putFileInfo($targetPath, ['checksum' => $checksum]);
480
-				} else if ($info->getChecksum() !== null && $info->getChecksum() !== '') {
481
-					$this->fileView->putFileInfo($this->path, ['checksum' => '']);
482
-				}
483
-
484
-				$this->fileView->unlockFile($targetPath, ILockingProvider::LOCK_SHARED);
485
-
486
-				return $info->getEtag();
487
-			} catch (\Exception $e) {
488
-				if ($partFile !== null) {
489
-					$targetStorage->unlink($targetInternalPath);
490
-				}
491
-				$this->convertToSabreException($e);
492
-			}
493
-		}
494
-
495
-		return null;
496
-	}
497
-
498
-	/**
499
-	 * Returns whether a part file is needed for the given storage
500
-	 * or whether the file can be assembled/uploaded directly on the
501
-	 * target storage.
502
-	 *
503
-	 * @param \OCP\Files\Storage $storage
504
-	 * @return bool true if the storage needs part file handling
505
-	 */
506
-	private function needsPartFile($storage) {
507
-		// TODO: in the future use ChunkHandler provided by storage
508
-		// and/or add method on Storage called "needsPartFile()"
509
-		return !$storage->instanceOfStorage('OCA\Files_Sharing\External\Storage') &&
510
-		!$storage->instanceOfStorage('OC\Files\Storage\OwnCloud');
511
-	}
512
-
513
-	/**
514
-	 * Convert the given exception to a SabreException instance
515
-	 *
516
-	 * @param \Exception $e
517
-	 *
518
-	 * @throws \Sabre\DAV\Exception
519
-	 */
520
-	private function convertToSabreException(\Exception $e) {
521
-		if ($e instanceof \Sabre\DAV\Exception) {
522
-			throw $e;
523
-		}
524
-		if ($e instanceof NotPermittedException) {
525
-			// a more general case - due to whatever reason the content could not be written
526
-			throw new Forbidden($e->getMessage(), 0, $e);
527
-		}
528
-		if ($e instanceof ForbiddenException) {
529
-			// the path for the file was forbidden
530
-			throw new DAVForbiddenException($e->getMessage(), $e->getRetry(), $e);
531
-		}
532
-		if ($e instanceof EntityTooLargeException) {
533
-			// the file is too big to be stored
534
-			throw new EntityTooLarge($e->getMessage(), 0, $e);
535
-		}
536
-		if ($e instanceof InvalidContentException) {
537
-			// the file content is not permitted
538
-			throw new UnsupportedMediaType($e->getMessage(), 0, $e);
539
-		}
540
-		if ($e instanceof InvalidPathException) {
541
-			// the path for the file was not valid
542
-			// TODO: find proper http status code for this case
543
-			throw new Forbidden($e->getMessage(), 0, $e);
544
-		}
545
-		if ($e instanceof LockedException || $e instanceof LockNotAcquiredException) {
546
-			// the file is currently being written to by another process
547
-			throw new FileLocked($e->getMessage(), $e->getCode(), $e);
548
-		}
549
-		if ($e instanceof GenericEncryptionException) {
550
-			// returning 503 will allow retry of the operation at a later point in time
551
-			throw new ServiceUnavailable('Encryption not ready: ' . $e->getMessage(), 0, $e);
552
-		}
553
-		if ($e instanceof StorageNotAvailableException) {
554
-			throw new ServiceUnavailable('Failed to write file contents: ' . $e->getMessage(), 0, $e);
555
-		}
556
-
557
-		throw new \Sabre\DAV\Exception($e->getMessage(), 0, $e);
558
-	}
559
-
560
-	/**
561
-	 * Get the checksum for this file
562
-	 *
563
-	 * @return string
564
-	 */
565
-	public function getChecksum() {
566
-		return $this->info->getChecksum();
567
-	}
214
+            if ($view) {
215
+                $this->emitPostHooks($exists);
216
+            }
217
+
218
+            $this->refreshInfo();
219
+
220
+            if (isset($request->server['HTTP_OC_CHECKSUM'])) {
221
+                $checksum = trim($request->server['HTTP_OC_CHECKSUM']);
222
+                $this->fileView->putFileInfo($this->path, ['checksum' => $checksum]);
223
+                $this->refreshInfo();
224
+            } else if ($this->getChecksum() !== null && $this->getChecksum() !== '') {
225
+                $this->fileView->putFileInfo($this->path, ['checksum' => '']);
226
+                $this->refreshInfo();
227
+            }
228
+
229
+        } catch (StorageNotAvailableException $e) {
230
+            throw new ServiceUnavailable("Failed to check file size: " . $e->getMessage());
231
+        }
232
+
233
+        return '"' . $this->info->getEtag() . '"';
234
+    }
235
+
236
+    private function getPartFileBasePath($path) {
237
+        $partFileInStorage = \OC::$server->getConfig()->getSystemValue('part_file_in_storage', true);
238
+        if ($partFileInStorage) {
239
+            return $path;
240
+        } else {
241
+            return md5($path); // will place it in the root of the view with a unique name
242
+        }
243
+    }
244
+
245
+    /**
246
+     * @param string $path
247
+     */
248
+    private function emitPreHooks($exists, $path = null) {
249
+        if (is_null($path)) {
250
+            $path = $this->path;
251
+        }
252
+        $hookPath = Filesystem::getView()->getRelativePath($this->fileView->getAbsolutePath($path));
253
+        $run = true;
254
+
255
+        if (!$exists) {
256
+            \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_create, array(
257
+                \OC\Files\Filesystem::signal_param_path => $hookPath,
258
+                \OC\Files\Filesystem::signal_param_run => &$run,
259
+            ));
260
+        } else {
261
+            \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_update, array(
262
+                \OC\Files\Filesystem::signal_param_path => $hookPath,
263
+                \OC\Files\Filesystem::signal_param_run => &$run,
264
+            ));
265
+        }
266
+        \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_write, array(
267
+            \OC\Files\Filesystem::signal_param_path => $hookPath,
268
+            \OC\Files\Filesystem::signal_param_run => &$run,
269
+        ));
270
+        return $run;
271
+    }
272
+
273
+    /**
274
+     * @param string $path
275
+     */
276
+    private function emitPostHooks($exists, $path = null) {
277
+        if (is_null($path)) {
278
+            $path = $this->path;
279
+        }
280
+        $hookPath = Filesystem::getView()->getRelativePath($this->fileView->getAbsolutePath($path));
281
+        if (!$exists) {
282
+            \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_create, array(
283
+                \OC\Files\Filesystem::signal_param_path => $hookPath
284
+            ));
285
+        } else {
286
+            \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_update, array(
287
+                \OC\Files\Filesystem::signal_param_path => $hookPath
288
+            ));
289
+        }
290
+        \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_write, array(
291
+            \OC\Files\Filesystem::signal_param_path => $hookPath
292
+        ));
293
+    }
294
+
295
+    /**
296
+     * Returns the data
297
+     *
298
+     * @return resource
299
+     * @throws Forbidden
300
+     * @throws ServiceUnavailable
301
+     */
302
+    public function get() {
303
+        //throw exception if encryption is disabled but files are still encrypted
304
+        try {
305
+            $res = $this->fileView->fopen(ltrim($this->path, '/'), 'rb');
306
+            if ($res === false) {
307
+                throw new ServiceUnavailable("Could not open file");
308
+            }
309
+            return $res;
310
+        } catch (GenericEncryptionException $e) {
311
+            // returning 503 will allow retry of the operation at a later point in time
312
+            throw new ServiceUnavailable("Encryption not ready: " . $e->getMessage());
313
+        } catch (StorageNotAvailableException $e) {
314
+            throw new ServiceUnavailable("Failed to open file: " . $e->getMessage());
315
+        } catch (ForbiddenException $ex) {
316
+            throw new DAVForbiddenException($ex->getMessage(), $ex->getRetry());
317
+        } catch (LockedException $e) {
318
+            throw new FileLocked($e->getMessage(), $e->getCode(), $e);
319
+        }
320
+    }
321
+
322
+    /**
323
+     * Delete the current file
324
+     *
325
+     * @throws Forbidden
326
+     * @throws ServiceUnavailable
327
+     */
328
+    public function delete() {
329
+        if (!$this->info->isDeletable()) {
330
+            throw new Forbidden();
331
+        }
332
+
333
+        try {
334
+            if (!$this->fileView->unlink($this->path)) {
335
+                // assume it wasn't possible to delete due to permissions
336
+                throw new Forbidden();
337
+            }
338
+        } catch (StorageNotAvailableException $e) {
339
+            throw new ServiceUnavailable("Failed to unlink: " . $e->getMessage());
340
+        } catch (ForbiddenException $ex) {
341
+            throw new DAVForbiddenException($ex->getMessage(), $ex->getRetry());
342
+        } catch (LockedException $e) {
343
+            throw new FileLocked($e->getMessage(), $e->getCode(), $e);
344
+        }
345
+    }
346
+
347
+    /**
348
+     * Returns the mime-type for a file
349
+     *
350
+     * If null is returned, we'll assume application/octet-stream
351
+     *
352
+     * @return string
353
+     */
354
+    public function getContentType() {
355
+        $mimeType = $this->info->getMimetype();
356
+
357
+        // PROPFIND needs to return the correct mime type, for consistency with the web UI
358
+        if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PROPFIND') {
359
+            return $mimeType;
360
+        }
361
+        return \OC::$server->getMimeTypeDetector()->getSecureMimeType($mimeType);
362
+    }
363
+
364
+    /**
365
+     * @return array|false
366
+     */
367
+    public function getDirectDownload() {
368
+        if (\OCP\App::isEnabled('encryption')) {
369
+            return [];
370
+        }
371
+        /** @var \OCP\Files\Storage $storage */
372
+        list($storage, $internalPath) = $this->fileView->resolvePath($this->path);
373
+        if (is_null($storage)) {
374
+            return [];
375
+        }
376
+
377
+        return $storage->getDirectDownload($internalPath);
378
+    }
379
+
380
+    /**
381
+     * @param resource $data
382
+     * @return null|string
383
+     * @throws Exception
384
+     * @throws BadRequest
385
+     * @throws NotImplemented
386
+     * @throws ServiceUnavailable
387
+     */
388
+    private function createFileChunked($data) {
389
+        list($path, $name) = \Sabre\HTTP\URLUtil::splitPath($this->path);
390
+
391
+        $info = \OC_FileChunking::decodeName($name);
392
+        if (empty($info)) {
393
+            throw new NotImplemented('Invalid chunk name');
394
+        }
395
+
396
+        $chunk_handler = new \OC_FileChunking($info);
397
+        $bytesWritten = $chunk_handler->store($info['index'], $data);
398
+
399
+        //detect aborted upload
400
+        if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT') {
401
+            if (isset($_SERVER['CONTENT_LENGTH'])) {
402
+                $expected = $_SERVER['CONTENT_LENGTH'];
403
+                if ($bytesWritten != $expected) {
404
+                    $chunk_handler->remove($info['index']);
405
+                    throw new BadRequest(
406
+                        'expected filesize ' . $expected . ' got ' . $bytesWritten);
407
+                }
408
+            }
409
+        }
410
+
411
+        if ($chunk_handler->isComplete()) {
412
+            list($storage,) = $this->fileView->resolvePath($path);
413
+            $needsPartFile = $this->needsPartFile($storage);
414
+            $partFile = null;
415
+
416
+            $targetPath = $path . '/' . $info['name'];
417
+            /** @var \OC\Files\Storage\Storage $targetStorage */
418
+            list($targetStorage, $targetInternalPath) = $this->fileView->resolvePath($targetPath);
419
+
420
+            $exists = $this->fileView->file_exists($targetPath);
421
+
422
+            try {
423
+                $this->fileView->lockFile($targetPath, ILockingProvider::LOCK_SHARED);
424
+
425
+                $this->emitPreHooks($exists, $targetPath);
426
+                $this->fileView->changeLock($targetPath, ILockingProvider::LOCK_EXCLUSIVE);
427
+                /** @var \OC\Files\Storage\Storage $targetStorage */
428
+                list($targetStorage, $targetInternalPath) = $this->fileView->resolvePath($targetPath);
429
+
430
+                if ($needsPartFile) {
431
+                    // we first assembly the target file as a part file
432
+                    $partFile = $this->getPartFileBasePath($path . '/' . $info['name']) . '.ocTransferId' . $info['transferid'] . '.part';
433
+                    /** @var \OC\Files\Storage\Storage $targetStorage */
434
+                    list($partStorage, $partInternalPath) = $this->fileView->resolvePath($partFile);
435
+
436
+
437
+                    $chunk_handler->file_assemble($partStorage, $partInternalPath);
438
+
439
+                    // here is the final atomic rename
440
+                    $renameOkay = $targetStorage->moveFromStorage($partStorage, $partInternalPath, $targetInternalPath);
441
+                    $fileExists = $targetStorage->file_exists($targetInternalPath);
442
+                    if ($renameOkay === false || $fileExists === false) {
443
+                        \OCP\Util::writeLog('webdav', '\OC\Files\Filesystem::rename() failed', \OCP\Util::ERROR);
444
+                        // only delete if an error occurred and the target file was already created
445
+                        if ($fileExists) {
446
+                            // set to null to avoid double-deletion when handling exception
447
+                            // stray part file
448
+                            $partFile = null;
449
+                            $targetStorage->unlink($targetInternalPath);
450
+                        }
451
+                        $this->fileView->changeLock($targetPath, ILockingProvider::LOCK_SHARED);
452
+                        throw new Exception('Could not rename part file assembled from chunks');
453
+                    }
454
+                } else {
455
+                    // assemble directly into the final file
456
+                    $chunk_handler->file_assemble($targetStorage, $targetInternalPath);
457
+                }
458
+
459
+                // allow sync clients to send the mtime along in a header
460
+                $request = \OC::$server->getRequest();
461
+                if (isset($request->server['HTTP_X_OC_MTIME'])) {
462
+                    if ($targetStorage->touch($targetInternalPath, $request->server['HTTP_X_OC_MTIME'])) {
463
+                        header('X-OC-MTime: accepted');
464
+                    }
465
+                }
466
+
467
+                // since we skipped the view we need to scan and emit the hooks ourselves
468
+                $targetStorage->getUpdater()->update($targetInternalPath);
469
+
470
+                $this->fileView->changeLock($targetPath, ILockingProvider::LOCK_SHARED);
471
+
472
+                $this->emitPostHooks($exists, $targetPath);
473
+
474
+                // FIXME: should call refreshInfo but can't because $this->path is not the of the final file
475
+                $info = $this->fileView->getFileInfo($targetPath);
476
+
477
+                if (isset($request->server['HTTP_OC_CHECKSUM'])) {
478
+                    $checksum = trim($request->server['HTTP_OC_CHECKSUM']);
479
+                    $this->fileView->putFileInfo($targetPath, ['checksum' => $checksum]);
480
+                } else if ($info->getChecksum() !== null && $info->getChecksum() !== '') {
481
+                    $this->fileView->putFileInfo($this->path, ['checksum' => '']);
482
+                }
483
+
484
+                $this->fileView->unlockFile($targetPath, ILockingProvider::LOCK_SHARED);
485
+
486
+                return $info->getEtag();
487
+            } catch (\Exception $e) {
488
+                if ($partFile !== null) {
489
+                    $targetStorage->unlink($targetInternalPath);
490
+                }
491
+                $this->convertToSabreException($e);
492
+            }
493
+        }
494
+
495
+        return null;
496
+    }
497
+
498
+    /**
499
+     * Returns whether a part file is needed for the given storage
500
+     * or whether the file can be assembled/uploaded directly on the
501
+     * target storage.
502
+     *
503
+     * @param \OCP\Files\Storage $storage
504
+     * @return bool true if the storage needs part file handling
505
+     */
506
+    private function needsPartFile($storage) {
507
+        // TODO: in the future use ChunkHandler provided by storage
508
+        // and/or add method on Storage called "needsPartFile()"
509
+        return !$storage->instanceOfStorage('OCA\Files_Sharing\External\Storage') &&
510
+        !$storage->instanceOfStorage('OC\Files\Storage\OwnCloud');
511
+    }
512
+
513
+    /**
514
+     * Convert the given exception to a SabreException instance
515
+     *
516
+     * @param \Exception $e
517
+     *
518
+     * @throws \Sabre\DAV\Exception
519
+     */
520
+    private function convertToSabreException(\Exception $e) {
521
+        if ($e instanceof \Sabre\DAV\Exception) {
522
+            throw $e;
523
+        }
524
+        if ($e instanceof NotPermittedException) {
525
+            // a more general case - due to whatever reason the content could not be written
526
+            throw new Forbidden($e->getMessage(), 0, $e);
527
+        }
528
+        if ($e instanceof ForbiddenException) {
529
+            // the path for the file was forbidden
530
+            throw new DAVForbiddenException($e->getMessage(), $e->getRetry(), $e);
531
+        }
532
+        if ($e instanceof EntityTooLargeException) {
533
+            // the file is too big to be stored
534
+            throw new EntityTooLarge($e->getMessage(), 0, $e);
535
+        }
536
+        if ($e instanceof InvalidContentException) {
537
+            // the file content is not permitted
538
+            throw new UnsupportedMediaType($e->getMessage(), 0, $e);
539
+        }
540
+        if ($e instanceof InvalidPathException) {
541
+            // the path for the file was not valid
542
+            // TODO: find proper http status code for this case
543
+            throw new Forbidden($e->getMessage(), 0, $e);
544
+        }
545
+        if ($e instanceof LockedException || $e instanceof LockNotAcquiredException) {
546
+            // the file is currently being written to by another process
547
+            throw new FileLocked($e->getMessage(), $e->getCode(), $e);
548
+        }
549
+        if ($e instanceof GenericEncryptionException) {
550
+            // returning 503 will allow retry of the operation at a later point in time
551
+            throw new ServiceUnavailable('Encryption not ready: ' . $e->getMessage(), 0, $e);
552
+        }
553
+        if ($e instanceof StorageNotAvailableException) {
554
+            throw new ServiceUnavailable('Failed to write file contents: ' . $e->getMessage(), 0, $e);
555
+        }
556
+
557
+        throw new \Sabre\DAV\Exception($e->getMessage(), 0, $e);
558
+    }
559
+
560
+    /**
561
+     * Get the checksum for this file
562
+     *
563
+     * @return string
564
+     */
565
+    public function getChecksum() {
566
+        return $this->info->getChecksum();
567
+    }
568 568
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/Principal.php 1 patch
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -40,196 +40,196 @@
 block discarded – undo
40 40
 
41 41
 class Principal implements BackendInterface {
42 42
 
43
-	/** @var IUserManager */
44
-	private $userManager;
45
-
46
-	/** @var IGroupManager */
47
-	private $groupManager;
48
-
49
-	/** @var string */
50
-	private $principalPrefix;
51
-
52
-	/** @var bool */
53
-	private $hasGroups;
54
-
55
-	/**
56
-	 * @param IUserManager $userManager
57
-	 * @param IGroupManager $groupManager
58
-	 * @param string $principalPrefix
59
-	 */
60
-	public function __construct(IUserManager $userManager,
61
-								IGroupManager $groupManager,
62
-								$principalPrefix = 'principals/users/') {
63
-		$this->userManager = $userManager;
64
-		$this->groupManager = $groupManager;
65
-		$this->principalPrefix = trim($principalPrefix, '/');
66
-		$this->hasGroups = ($principalPrefix === 'principals/users/');
67
-	}
68
-
69
-	/**
70
-	 * Returns a list of principals based on a prefix.
71
-	 *
72
-	 * This prefix will often contain something like 'principals'. You are only
73
-	 * expected to return principals that are in this base path.
74
-	 *
75
-	 * You are expected to return at least a 'uri' for every user, you can
76
-	 * return any additional properties if you wish so. Common properties are:
77
-	 *   {DAV:}displayname
78
-	 *
79
-	 * @param string $prefixPath
80
-	 * @return string[]
81
-	 */
82
-	public function getPrincipalsByPrefix($prefixPath) {
83
-		$principals = [];
84
-
85
-		if ($prefixPath === $this->principalPrefix) {
86
-			foreach($this->userManager->search('') as $user) {
87
-				$principals[] = $this->userToPrincipal($user);
88
-			}
89
-		}
90
-
91
-		return $principals;
92
-	}
93
-
94
-	/**
95
-	 * Returns a specific principal, specified by it's path.
96
-	 * The returned structure should be the exact same as from
97
-	 * getPrincipalsByPrefix.
98
-	 *
99
-	 * @param string $path
100
-	 * @return array
101
-	 */
102
-	public function getPrincipalByPath($path) {
103
-		list($prefix, $name) = URLUtil::splitPath($path);
104
-
105
-		if ($prefix === $this->principalPrefix) {
106
-			$user = $this->userManager->get($name);
107
-
108
-			if (!is_null($user)) {
109
-				return $this->userToPrincipal($user);
110
-			}
111
-		}
112
-		return null;
113
-	}
114
-
115
-	/**
116
-	 * Returns the list of members for a group-principal
117
-	 *
118
-	 * @param string $principal
119
-	 * @return string[]
120
-	 * @throws Exception
121
-	 */
122
-	public function getGroupMemberSet($principal) {
123
-		// TODO: for now the group principal has only one member, the user itself
124
-		$principal = $this->getPrincipalByPath($principal);
125
-		if (!$principal) {
126
-			throw new Exception('Principal not found');
127
-		}
128
-
129
-		return [$principal['uri']];
130
-	}
131
-
132
-	/**
133
-	 * Returns the list of groups a principal is a member of
134
-	 *
135
-	 * @param string $principal
136
-	 * @param bool $needGroups
137
-	 * @return array
138
-	 * @throws Exception
139
-	 */
140
-	public function getGroupMembership($principal, $needGroups = false) {
141
-		list($prefix, $name) = URLUtil::splitPath($principal);
142
-
143
-		if ($prefix === $this->principalPrefix) {
144
-			$user = $this->userManager->get($name);
145
-			if (!$user) {
146
-				throw new Exception('Principal not found');
147
-			}
148
-
149
-			if ($this->hasGroups || $needGroups) {
150
-				$groups = $this->groupManager->getUserGroups($user);
151
-				$groups = array_map(function($group) {
152
-					/** @var IGroup $group */
153
-					return 'principals/groups/' . $group->getGID();
154
-				}, $groups);
155
-
156
-				return $groups;
157
-			}
158
-		}
159
-		return [];
160
-	}
161
-
162
-	/**
163
-	 * Updates the list of group members for a group principal.
164
-	 *
165
-	 * The principals should be passed as a list of uri's.
166
-	 *
167
-	 * @param string $principal
168
-	 * @param string[] $members
169
-	 * @throws Exception
170
-	 */
171
-	public function setGroupMemberSet($principal, array $members) {
172
-		throw new Exception('Setting members of the group is not supported yet');
173
-	}
174
-
175
-	/**
176
-	 * @param string $path
177
-	 * @param PropPatch $propPatch
178
-	 * @return int
179
-	 */
180
-	function updatePrincipal($path, PropPatch $propPatch) {
181
-		return 0;
182
-	}
183
-
184
-	/**
185
-	 * @param string $prefixPath
186
-	 * @param array $searchProperties
187
-	 * @param string $test
188
-	 * @return array
189
-	 */
190
-	function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof') {
191
-		return [];
192
-	}
193
-
194
-	/**
195
-	 * @param string $uri
196
-	 * @param string $principalPrefix
197
-	 * @return string
198
-	 */
199
-	function findByUri($uri, $principalPrefix) {
200
-		if (substr($uri, 0, 7) === 'mailto:') {
201
-			$email = substr($uri, 7);
202
-			$users = $this->userManager->getByEmail($email);
203
-			if (count($users) === 1) {
204
-				return $this->principalPrefix . '/' . $users[0]->getUID();
205
-			}
206
-		}
207
-
208
-		return '';
209
-	}
210
-
211
-	/**
212
-	 * @param IUser $user
213
-	 * @return array
214
-	 */
215
-	protected function userToPrincipal($user) {
216
-		$userId = $user->getUID();
217
-		$displayName = $user->getDisplayName();
218
-		$principal = [
219
-				'uri' => $this->principalPrefix . '/' . $userId,
220
-				'{DAV:}displayname' => is_null($displayName) ? $userId : $displayName,
221
-		];
222
-
223
-		$email = $user->getEMailAddress();
224
-		if (!empty($email)) {
225
-			$principal['{http://sabredav.org/ns}email-address'] = $email;
226
-			return $principal;
227
-		}
228
-		return $principal;
229
-	}
230
-
231
-	public function getPrincipalPrefix() {
232
-		return $this->principalPrefix;
233
-	}
43
+    /** @var IUserManager */
44
+    private $userManager;
45
+
46
+    /** @var IGroupManager */
47
+    private $groupManager;
48
+
49
+    /** @var string */
50
+    private $principalPrefix;
51
+
52
+    /** @var bool */
53
+    private $hasGroups;
54
+
55
+    /**
56
+     * @param IUserManager $userManager
57
+     * @param IGroupManager $groupManager
58
+     * @param string $principalPrefix
59
+     */
60
+    public function __construct(IUserManager $userManager,
61
+                                IGroupManager $groupManager,
62
+                                $principalPrefix = 'principals/users/') {
63
+        $this->userManager = $userManager;
64
+        $this->groupManager = $groupManager;
65
+        $this->principalPrefix = trim($principalPrefix, '/');
66
+        $this->hasGroups = ($principalPrefix === 'principals/users/');
67
+    }
68
+
69
+    /**
70
+     * Returns a list of principals based on a prefix.
71
+     *
72
+     * This prefix will often contain something like 'principals'. You are only
73
+     * expected to return principals that are in this base path.
74
+     *
75
+     * You are expected to return at least a 'uri' for every user, you can
76
+     * return any additional properties if you wish so. Common properties are:
77
+     *   {DAV:}displayname
78
+     *
79
+     * @param string $prefixPath
80
+     * @return string[]
81
+     */
82
+    public function getPrincipalsByPrefix($prefixPath) {
83
+        $principals = [];
84
+
85
+        if ($prefixPath === $this->principalPrefix) {
86
+            foreach($this->userManager->search('') as $user) {
87
+                $principals[] = $this->userToPrincipal($user);
88
+            }
89
+        }
90
+
91
+        return $principals;
92
+    }
93
+
94
+    /**
95
+     * Returns a specific principal, specified by it's path.
96
+     * The returned structure should be the exact same as from
97
+     * getPrincipalsByPrefix.
98
+     *
99
+     * @param string $path
100
+     * @return array
101
+     */
102
+    public function getPrincipalByPath($path) {
103
+        list($prefix, $name) = URLUtil::splitPath($path);
104
+
105
+        if ($prefix === $this->principalPrefix) {
106
+            $user = $this->userManager->get($name);
107
+
108
+            if (!is_null($user)) {
109
+                return $this->userToPrincipal($user);
110
+            }
111
+        }
112
+        return null;
113
+    }
114
+
115
+    /**
116
+     * Returns the list of members for a group-principal
117
+     *
118
+     * @param string $principal
119
+     * @return string[]
120
+     * @throws Exception
121
+     */
122
+    public function getGroupMemberSet($principal) {
123
+        // TODO: for now the group principal has only one member, the user itself
124
+        $principal = $this->getPrincipalByPath($principal);
125
+        if (!$principal) {
126
+            throw new Exception('Principal not found');
127
+        }
128
+
129
+        return [$principal['uri']];
130
+    }
131
+
132
+    /**
133
+     * Returns the list of groups a principal is a member of
134
+     *
135
+     * @param string $principal
136
+     * @param bool $needGroups
137
+     * @return array
138
+     * @throws Exception
139
+     */
140
+    public function getGroupMembership($principal, $needGroups = false) {
141
+        list($prefix, $name) = URLUtil::splitPath($principal);
142
+
143
+        if ($prefix === $this->principalPrefix) {
144
+            $user = $this->userManager->get($name);
145
+            if (!$user) {
146
+                throw new Exception('Principal not found');
147
+            }
148
+
149
+            if ($this->hasGroups || $needGroups) {
150
+                $groups = $this->groupManager->getUserGroups($user);
151
+                $groups = array_map(function($group) {
152
+                    /** @var IGroup $group */
153
+                    return 'principals/groups/' . $group->getGID();
154
+                }, $groups);
155
+
156
+                return $groups;
157
+            }
158
+        }
159
+        return [];
160
+    }
161
+
162
+    /**
163
+     * Updates the list of group members for a group principal.
164
+     *
165
+     * The principals should be passed as a list of uri's.
166
+     *
167
+     * @param string $principal
168
+     * @param string[] $members
169
+     * @throws Exception
170
+     */
171
+    public function setGroupMemberSet($principal, array $members) {
172
+        throw new Exception('Setting members of the group is not supported yet');
173
+    }
174
+
175
+    /**
176
+     * @param string $path
177
+     * @param PropPatch $propPatch
178
+     * @return int
179
+     */
180
+    function updatePrincipal($path, PropPatch $propPatch) {
181
+        return 0;
182
+    }
183
+
184
+    /**
185
+     * @param string $prefixPath
186
+     * @param array $searchProperties
187
+     * @param string $test
188
+     * @return array
189
+     */
190
+    function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof') {
191
+        return [];
192
+    }
193
+
194
+    /**
195
+     * @param string $uri
196
+     * @param string $principalPrefix
197
+     * @return string
198
+     */
199
+    function findByUri($uri, $principalPrefix) {
200
+        if (substr($uri, 0, 7) === 'mailto:') {
201
+            $email = substr($uri, 7);
202
+            $users = $this->userManager->getByEmail($email);
203
+            if (count($users) === 1) {
204
+                return $this->principalPrefix . '/' . $users[0]->getUID();
205
+            }
206
+        }
207
+
208
+        return '';
209
+    }
210
+
211
+    /**
212
+     * @param IUser $user
213
+     * @return array
214
+     */
215
+    protected function userToPrincipal($user) {
216
+        $userId = $user->getUID();
217
+        $displayName = $user->getDisplayName();
218
+        $principal = [
219
+                'uri' => $this->principalPrefix . '/' . $userId,
220
+                '{DAV:}displayname' => is_null($displayName) ? $userId : $displayName,
221
+        ];
222
+
223
+        $email = $user->getEMailAddress();
224
+        if (!empty($email)) {
225
+            $principal['{http://sabredav.org/ns}email-address'] = $email;
226
+            return $principal;
227
+        }
228
+        return $principal;
229
+    }
230
+
231
+    public function getPrincipalPrefix() {
232
+        return $this->principalPrefix;
233
+    }
234 234
 
235 235
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/Exception/Forbidden.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -24,42 +24,42 @@
 block discarded – undo
24 24
 
25 25
 class Forbidden extends \Sabre\DAV\Exception\Forbidden {
26 26
 
27
-	const NS_OWNCLOUD = 'http://owncloud.org/ns';
27
+    const NS_OWNCLOUD = 'http://owncloud.org/ns';
28 28
 
29
-	/**
30
-	 * @var bool
31
-	 */
32
-	private $retry;
29
+    /**
30
+     * @var bool
31
+     */
32
+    private $retry;
33 33
 
34
-	/**
35
-	 * @param string $message
36
-	 * @param bool $retry
37
-	 * @param \Exception $previous
38
-	 */
39
-	public function __construct($message, $retry = false, \Exception $previous = null) {
40
-		parent::__construct($message, 0, $previous);
41
-		$this->retry = $retry;
42
-	}
34
+    /**
35
+     * @param string $message
36
+     * @param bool $retry
37
+     * @param \Exception $previous
38
+     */
39
+    public function __construct($message, $retry = false, \Exception $previous = null) {
40
+        parent::__construct($message, 0, $previous);
41
+        $this->retry = $retry;
42
+    }
43 43
 
44
-	/**
45
-	 * This method allows the exception to include additional information
46
-	 * into the WebDAV error response
47
-	 *
48
-	 * @param \Sabre\DAV\Server $server
49
-	 * @param \DOMElement $errorNode
50
-	 * @return void
51
-	 */
52
-	public function serialize(\Sabre\DAV\Server $server,\DOMElement $errorNode) {
44
+    /**
45
+     * This method allows the exception to include additional information
46
+     * into the WebDAV error response
47
+     *
48
+     * @param \Sabre\DAV\Server $server
49
+     * @param \DOMElement $errorNode
50
+     * @return void
51
+     */
52
+    public function serialize(\Sabre\DAV\Server $server,\DOMElement $errorNode) {
53 53
 
54
-		// set ownCloud namespace
55
-		$errorNode->setAttribute('xmlns:o', self::NS_OWNCLOUD);
54
+        // set ownCloud namespace
55
+        $errorNode->setAttribute('xmlns:o', self::NS_OWNCLOUD);
56 56
 
57
-		// adding the retry node
58
-		$error = $errorNode->ownerDocument->createElementNS('o:','o:retry', var_export($this->retry, true));
59
-		$errorNode->appendChild($error);
57
+        // adding the retry node
58
+        $error = $errorNode->ownerDocument->createElementNS('o:','o:retry', var_export($this->retry, true));
59
+        $errorNode->appendChild($error);
60 60
 
61
-		// adding the message node
62
-		$error = $errorNode->ownerDocument->createElementNS('o:','o:reason', $this->getMessage());
63
-		$errorNode->appendChild($error);
64
-	}
61
+        // adding the message node
62
+        $error = $errorNode->ownerDocument->createElementNS('o:','o:reason', $this->getMessage());
63
+        $errorNode->appendChild($error);
64
+    }
65 65
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/Exception/InvalidPath.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -26,53 +26,53 @@
 block discarded – undo
26 26
 
27 27
 class InvalidPath extends Exception {
28 28
 
29
-	const NS_OWNCLOUD = 'http://owncloud.org/ns';
29
+    const NS_OWNCLOUD = 'http://owncloud.org/ns';
30 30
 
31
-	/**
32
-	 * @var bool
33
-	 */
34
-	private $retry;
31
+    /**
32
+     * @var bool
33
+     */
34
+    private $retry;
35 35
 
36
-	/**
37
-	 * @param string $message
38
-	 * @param bool $retry
39
-	 */
40
-	public function __construct($message, $retry = false) {
41
-		parent::__construct($message);
42
-		$this->retry = $retry;
43
-	}
36
+    /**
37
+     * @param string $message
38
+     * @param bool $retry
39
+     */
40
+    public function __construct($message, $retry = false) {
41
+        parent::__construct($message);
42
+        $this->retry = $retry;
43
+    }
44 44
 
45
-	/**
46
-	 * Returns the HTTP status code for this exception
47
-	 *
48
-	 * @return int
49
-	 */
50
-	public function getHTTPCode() {
45
+    /**
46
+     * Returns the HTTP status code for this exception
47
+     *
48
+     * @return int
49
+     */
50
+    public function getHTTPCode() {
51 51
 
52
-		return 400;
52
+        return 400;
53 53
 
54
-	}
54
+    }
55 55
 
56
-	/**
57
-	 * This method allows the exception to include additional information
58
-	 * into the WebDAV error response
59
-	 *
60
-	 * @param \Sabre\DAV\Server $server
61
-	 * @param \DOMElement $errorNode
62
-	 * @return void
63
-	 */
64
-	public function serialize(\Sabre\DAV\Server $server,\DOMElement $errorNode) {
56
+    /**
57
+     * This method allows the exception to include additional information
58
+     * into the WebDAV error response
59
+     *
60
+     * @param \Sabre\DAV\Server $server
61
+     * @param \DOMElement $errorNode
62
+     * @return void
63
+     */
64
+    public function serialize(\Sabre\DAV\Server $server,\DOMElement $errorNode) {
65 65
 
66
-		// set ownCloud namespace
67
-		$errorNode->setAttribute('xmlns:o', self::NS_OWNCLOUD);
66
+        // set ownCloud namespace
67
+        $errorNode->setAttribute('xmlns:o', self::NS_OWNCLOUD);
68 68
 
69
-		// adding the retry node
70
-		$error = $errorNode->ownerDocument->createElementNS('o:','o:retry', var_export($this->retry, true));
71
-		$errorNode->appendChild($error);
69
+        // adding the retry node
70
+        $error = $errorNode->ownerDocument->createElementNS('o:','o:retry', var_export($this->retry, true));
71
+        $errorNode->appendChild($error);
72 72
 
73
-		// adding the message node
74
-		$error = $errorNode->ownerDocument->createElementNS('o:','o:reason', $this->getMessage());
75
-		$errorNode->appendChild($error);
76
-	}
73
+        // adding the message node
74
+        $error = $errorNode->ownerDocument->createElementNS('o:','o:reason', $this->getMessage());
75
+        $errorNode->appendChild($error);
76
+    }
77 77
 
78 78
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/Exception/PasswordLoginForbidden.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -29,27 +29,27 @@
 block discarded – undo
29 29
 
30 30
 class PasswordLoginForbidden extends NotAuthenticated {
31 31
 
32
-	const NS_OWNCLOUD = 'http://owncloud.org/ns';
33
-
34
-	public function getHTTPCode() {
35
-		return 401;
36
-	}
37
-
38
-	/**
39
-	 * This method allows the exception to include additional information
40
-	 * into the WebDAV error response
41
-	 *
42
-	 * @param Server $server
43
-	 * @param DOMElement $errorNode
44
-	 * @return void
45
-	 */
46
-	public function serialize(Server $server, DOMElement $errorNode) {
47
-
48
-		// set ownCloud namespace
49
-		$errorNode->setAttribute('xmlns:o', self::NS_OWNCLOUD);
50
-
51
-		$error = $errorNode->ownerDocument->createElementNS('o:', 'o:hint', 'password login forbidden');
52
-		$errorNode->appendChild($error);
53
-	}
32
+    const NS_OWNCLOUD = 'http://owncloud.org/ns';
33
+
34
+    public function getHTTPCode() {
35
+        return 401;
36
+    }
37
+
38
+    /**
39
+     * This method allows the exception to include additional information
40
+     * into the WebDAV error response
41
+     *
42
+     * @param Server $server
43
+     * @param DOMElement $errorNode
44
+     * @return void
45
+     */
46
+    public function serialize(Server $server, DOMElement $errorNode) {
47
+
48
+        // set ownCloud namespace
49
+        $errorNode->setAttribute('xmlns:o', self::NS_OWNCLOUD);
50
+
51
+        $error = $errorNode->ownerDocument->createElementNS('o:', 'o:hint', 'password login forbidden');
52
+        $errorNode->appendChild($error);
53
+    }
54 54
 
55 55
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/Exception/FileLocked.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -30,20 +30,20 @@
 block discarded – undo
30 30
 
31 31
 class FileLocked extends \Sabre\DAV\Exception {
32 32
 
33
-	public function __construct($message = "", $code = 0, Exception $previous = null) {
34
-		if($previous instanceof \OCP\Files\LockNotAcquiredException) {
35
-			$message = sprintf('Target file %s is locked by another process.', $previous->path);
36
-		}
37
-		parent::__construct($message, $code, $previous);
38
-	}
33
+    public function __construct($message = "", $code = 0, Exception $previous = null) {
34
+        if($previous instanceof \OCP\Files\LockNotAcquiredException) {
35
+            $message = sprintf('Target file %s is locked by another process.', $previous->path);
36
+        }
37
+        parent::__construct($message, $code, $previous);
38
+    }
39 39
 
40
-	/**
41
-	 * Returns the HTTP status code for this exception
42
-	 *
43
-	 * @return int
44
-	 */
45
-	public function getHTTPCode() {
40
+    /**
41
+     * Returns the HTTP status code for this exception
42
+     *
43
+     * @return int
44
+     */
45
+    public function getHTTPCode() {
46 46
 
47
-		return 423;
48
-	}
47
+        return 423;
48
+    }
49 49
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/Exception/UnsupportedMediaType.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -31,15 +31,15 @@
 block discarded – undo
31 31
  */
32 32
 class UnsupportedMediaType extends \Sabre\DAV\Exception {
33 33
 
34
-	/**
35
-	 * Returns the HTTP status code for this exception
36
-	 *
37
-	 * @return int
38
-	 */
39
-	public function getHTTPCode() {
34
+    /**
35
+     * Returns the HTTP status code for this exception
36
+     *
37
+     * @return int
38
+     */
39
+    public function getHTTPCode() {
40 40
 
41
-		return 415;
41
+        return 415;
42 42
 
43
-	}
43
+    }
44 44
 
45 45
 }
Please login to merge, or discard this patch.