Skip to content
Snippets Groups Projects
Commit 8f96ef14 authored by Vincent Petry's avatar Vincent Petry
Browse files

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.
parent 53eff979
Branches
No related tags found
No related merge requests found
......@@ -141,6 +141,9 @@ class Quota extends Wrapper {
*/
public function fopen($path, $mode) {
$source = $this->storage->fopen($path, $mode);
// 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
......@@ -148,9 +151,23 @@ class Quota extends Wrapper {
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment