diff --git a/lib/private/Files/Storage/Wrapper/Quota.php b/lib/private/Files/Storage/Wrapper/Quota.php
index 62d3335987ce7c81e3e58f80fe49183e3de2ab23..4b99af46b0294e85c505a76674e1a104c2d7eef3 100644
--- a/lib/private/Files/Storage/Wrapper/Quota.php
+++ b/lib/private/Files/Storage/Wrapper/Quota.php
@@ -161,7 +161,7 @@ class Quota extends Wrapper {
 			$free = $this->free_space($path);
 			if ($source && $free >= 0 && $mode !== 'r' && $mode !== 'rb') {
 				// only apply quota for files, not metadata, trash or others
-				if (strpos(ltrim($path, '/'), 'files/') === 0) {
+				if ($this->shouldApplyQuota($path)) {
 					return \OC\Files\Stream\Quota::wrap($source, $free);
 				}
 			}
@@ -182,6 +182,13 @@ class Quota extends Wrapper {
 		return ($extension === 'part');
 	}
 
+	/**
+	 * Only apply quota for files, not metadata, trash or others
+	 */
+	private function shouldApplyQuota(string $path): bool {
+		return strpos(ltrim($path, '/'), 'files/') === 0;
+	}
+
 	/**
 	 * @param IStorage $sourceStorage
 	 * @param string $sourceInternalPath
@@ -214,7 +221,7 @@ class Quota extends Wrapper {
 
 	public function mkdir($path) {
 		$free = $this->free_space($path);
-		if ($free === 0.0) {
+		if ($this->shouldApplyQuota($path) && $free === 0.0) {
 			return false;
 		}