diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-02-16 14:39:04 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-02-17 11:52:49 +0100 |
commit | 8f96ef147f7ddf517e83e10b2dab5f4e94da9f06 (patch) | |
tree | 474d0d6cdc1ebdb9a4bb4a5b4e014cb6c2186317 /lib/private/files/storage/wrapper | |
parent | 53eff9792f1ae5ece49dfe79b40d1d73ae530688 (diff) | |
download | nextcloud-server-8f96ef147f7ddf517e83e10b2dab5f4e94da9f06.tar.gz nextcloud-server-8f96ef147f7ddf517e83e10b2dab5f4e94da9f06.zip |
Don't apply quota in stream wrapper for part files
When overwriting shared files as recipient, the part file is written on
the uploader's storage before overwriting the target file.
If the uploader has no quota left, they should still be able to
overwrite that file with Webdav. To make this work, they need to be able
to write the part file to their own storage first.
Diffstat (limited to 'lib/private/files/storage/wrapper')
-rw-r--r-- | lib/private/files/storage/wrapper/quota.php | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/lib/private/files/storage/wrapper/quota.php b/lib/private/files/storage/wrapper/quota.php index 844505679df..500677b092e 100644 --- a/lib/private/files/storage/wrapper/quota.php +++ b/lib/private/files/storage/wrapper/quota.php @@ -141,17 +141,34 @@ class Quota extends Wrapper { */ public function fopen($path, $mode) { $source = $this->storage->fopen($path, $mode); - $free = $this->free_space(''); - if ($source && $free >= 0 && $mode !== 'r' && $mode !== 'rb') { - // only apply quota for files, not metadata, trash or others - if (strpos(ltrim($path, '/'), 'files/') === 0) { - return \OC\Files\Stream\Quota::wrap($source, $free); + + // don't apply quota for part files + if (!$this->isPartFile($path)) { + $free = $this->free_space(''); + if ($source && $free >= 0 && $mode !== 'r' && $mode !== 'rb') { + // only apply quota for files, not metadata, trash or others + if (strpos(ltrim($path, '/'), 'files/') === 0) { + return \OC\Files\Stream\Quota::wrap($source, $free); + } } } return $source; } /** + * Checks whether the given path is a part file + * + * @param string $path Path that may identify a .part file + * @return string File path without .part extension + * @note this is needed for reusing keys + */ + private function isPartFile($path) { + $extension = pathinfo($path, PATHINFO_EXTENSION); + + return ($extension === 'part'); + } + + /** * @param \OCP\Files\Storage $sourceStorage * @param string $sourceInternalPath * @param string $targetInternalPath |