@@ -120,19 +120,20 @@ public function copy(string $source, string $target): bool {
120120
121121 #[\Override]
122122 public function fopen (string $ path , string $ mode ) {
123- if (!$ this ->hasQuota ()) {
123+ if (!$ this ->hasQuota () || $ this -> isPartFile ( $ path ) ) {
124124 return $ this ->getWrapperStorage ()->fopen ($ path , $ mode );
125125 }
126- $ source = $ this ->getWrapperStorage ()->fopen ($ path , $ mode );
127126
128- // don't apply quota for part files
129- if (!$ this ->isPartFile ($ path )) {
130- $ free = $ this ->free_space ($ path );
131- if ($ source && (is_int ($ free ) || is_float ($ free )) && $ free >= 0 && $ mode !== 'r ' && $ mode !== 'rb ' ) {
132- // only apply quota for files, not metadata, trash or others
133- if ($ this ->shouldApplyQuota ($ path )) {
134- return \OC \Files \Stream \Quota::wrap ($ source , $ free );
135- }
127+ $ free = $ this ->free_space ($ path );
128+ if ($ this ->shouldApplyQuota ($ path ) && $ free == 0 ) {
129+ return false ;
130+ }
131+
132+ $ source = $ this ->getWrapperStorage ()->fopen ($ path , $ mode );
133+ if ($ source && (is_int ($ free ) || is_float ($ free )) && $ free >= 0 && $ mode !== 'r ' && $ mode !== 'rb ' ) {
134+ // only apply quota for files, not metadata, trash or others
135+ if ($ this ->shouldApplyQuota ($ path )) {
136+ return \OC \Files \Stream \Quota::wrap ($ source , $ free );
136137 }
137138 }
138139
0 commit comments