Skip to content

Commit 00645c6

Browse files
authored
Merge pull request #35940 from nextcloud/backport/35734/stable24
[stable24] Quota value as float for 32-bit systems
2 parents 6aae233 + 6def133 commit 00645c6

10 files changed

Lines changed: 27 additions & 30 deletions

File tree

lib/private/Files/Storage/Common.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ public function test() {
472472
* get the free space in the storage
473473
*
474474
* @param string $path
475-
* @return int|false
475+
* @return int|float|false
476476
*/
477477
public function free_space($path) {
478478
return \OCP\Files\FileInfo::SPACE_UNKNOWN;
@@ -518,7 +518,6 @@ public function getDirectDownload($path) {
518518
* @throws InvalidPathException
519519
*/
520520
public function verifyPath($path, $fileName) {
521-
522521
// verify empty and dot files
523522
$trimmed = trim($fileName);
524523
if ($trimmed === '') {

lib/private/Files/Storage/DAV.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ public function touch($path, $mtime = null) {
487487
/**
488488
* @param string $path
489489
* @param mixed $data
490-
* @return int|false
490+
* @return int|float|false
491491
*/
492492
public function file_put_contents($path, $data) {
493493
$path = $this->cleanPath($path);

lib/private/Files/Storage/Local.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t
591591
}
592592

593593
public function writeStream(string $path, $stream, int $size = null): int {
594+
/** @var int|false $result We consider here that returned size will never be a float because we write less than 4GB */
594595
$result = $this->file_put_contents($path, $stream);
595596
if (is_resource($stream)) {
596597
fclose($stream);

lib/private/Files/Storage/Wrapper/Encoding.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
* the actual given name and then try its NFD form.
4141
*/
4242
class Encoding extends Wrapper {
43-
4443
/**
4544
* @var ICache
4645
*/
@@ -213,7 +212,7 @@ public function filetype($path) {
213212
* The result for filesize when called on a folder is required to be 0
214213
*
215214
* @param string $path
216-
* @return int|bool
215+
* @return int|float|bool
217216
*/
218217
public function filesize($path) {
219218
return $this->storage->filesize($this->findPathToUse($path));
@@ -315,7 +314,7 @@ public function file_get_contents($path) {
315314
*
316315
* @param string $path
317316
* @param mixed $data
318-
* @return int|false
317+
* @return int|float|false
319318
*/
320319
public function file_put_contents($path, $data) {
321320
return $this->storage->file_put_contents($this->findPathToUse($path), $data);
@@ -400,7 +399,7 @@ public function hash($type, $path, $raw = false) {
400399
* see https://www.php.net/manual/en/function.free_space.php
401400
*
402401
* @param string $path
403-
* @return int|bool
402+
* @return int|float|bool
404403
*/
405404
public function free_space($path) {
406405
return $this->storage->free_space($this->findPathToUse($path));

lib/private/Files/Storage/Wrapper/Jail.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public function filetype($path) {
160160
* The result for filesize when called on a folder is required to be 0
161161
*
162162
* @param string $path
163-
* @return int|bool
163+
* @return int|float|bool
164164
*/
165165
public function filesize($path) {
166166
return $this->getWrapperStorage()->filesize($this->getUnjailedPath($path));
@@ -262,7 +262,7 @@ public function file_get_contents($path) {
262262
*
263263
* @param string $path
264264
* @param mixed $data
265-
* @return int|false
265+
* @return int|float|false
266266
*/
267267
public function file_put_contents($path, $data) {
268268
return $this->getWrapperStorage()->file_put_contents($this->getUnjailedPath($path), $data);
@@ -338,7 +338,7 @@ public function hash($type, $path, $raw = false) {
338338
* see https://www.php.net/manual/en/function.free_space.php
339339
*
340340
* @param string $path
341-
* @return int|bool
341+
* @return int|float|bool
342342
*/
343343
public function free_space($path) {
344344
return $this->getWrapperStorage()->free_space($this->getUnjailedPath($path));

lib/private/Files/Storage/Wrapper/Quota.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@
3737
use OCP\Files\Storage\IStorage;
3838

3939
class Quota extends Wrapper {
40-
41-
/**
42-
* @var int $quota
43-
*/
40+
/** @var int|float int on 64bits, float on 32bits for bigint */
4441
protected $quota;
4542

4643
/**
@@ -61,15 +58,16 @@ public function __construct($parameters) {
6158
}
6259

6360
/**
64-
* @return int quota value
61+
* @return int|float quota value
6562
*/
6663
public function getQuota() {
6764
return $this->quota;
6865
}
6966

7067
/**
7168
* @param string $path
72-
* @param \OC\Files\Storage\Storage $storage
69+
* @param IStorage $storage
70+
* @return int|float
7371
*/
7472
protected function getSize($path, $storage = null) {
7573
if ($this->config->getValue('quota_include_external_storage', false)) {
@@ -97,7 +95,7 @@ protected function getSize($path, $storage = null) {
9795
* Get free space as limited by the quota
9896
*
9997
* @param string $path
100-
* @return int|bool
98+
* @return int|float|bool
10199
*/
102100
public function free_space($path) {
103101
if ($this->quota < 0 || strpos($path, 'cache') === 0 || strpos($path, 'uploads') === 0) {
@@ -125,7 +123,7 @@ public function free_space($path) {
125123
*
126124
* @param string $path
127125
* @param mixed $data
128-
* @return int|false
126+
* @return int|float|false
129127
*/
130128
public function file_put_contents($path, $data) {
131129
$free = $this->free_space($path);
@@ -165,7 +163,7 @@ public function fopen($path, $mode) {
165163
// don't apply quota for part files
166164
if (!$this->isPartFile($path)) {
167165
$free = $this->free_space($path);
168-
if ($source && is_int($free) && $free >= 0 && $mode !== 'r' && $mode !== 'rb') {
166+
if ($source && (is_int($free) || is_float($free)) && $free >= 0 && $mode !== 'r' && $mode !== 'rb') {
169167
// only apply quota for files, not metadata, trash or others
170168
if ($this->shouldApplyQuota($path)) {
171169
return \OC\Files\Stream\Quota::wrap($source, $free);
@@ -179,7 +177,7 @@ public function fopen($path, $mode) {
179177
* Checks whether the given path is a part file
180178
*
181179
* @param string $path Path that may identify a .part file
182-
* @return string File path without .part extension
180+
* @return bool
183181
* @note this is needed for reusing keys
184182
*/
185183
private function isPartFile($path) {

lib/private/Files/Storage/Wrapper/Wrapper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function filetype($path) {
150150
* The result for filesize when called on a folder is required to be 0
151151
*
152152
* @param string $path
153-
* @return int|bool
153+
* @return int|float|bool
154154
*/
155155
public function filesize($path) {
156156
return $this->getWrapperStorage()->filesize($path);
@@ -252,7 +252,7 @@ public function file_get_contents($path) {
252252
*
253253
* @param string $path
254254
* @param mixed $data
255-
* @return int|false
255+
* @return int|float|false
256256
*/
257257
public function file_put_contents($path, $data) {
258258
return $this->getWrapperStorage()->file_put_contents($path, $data);
@@ -328,7 +328,7 @@ public function hash($type, $path, $raw = false) {
328328
* see https://www.php.net/manual/en/function.free_space.php
329329
*
330330
* @param string $path
331-
* @return int|bool
331+
* @return int|float|bool
332332
*/
333333
public function free_space($path) {
334334
return $this->getWrapperStorage()->free_space($path);

lib/private/LargeFileHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function formatUnsignedInteger($number) {
9595
*
9696
* @param string $filename Path to the file.
9797
*
98-
* @return null|int|float Number of bytes as number (float or int) or
98+
* @return int|float Number of bytes as number (float or int) or
9999
* null on failure.
100100
*/
101101
public function getFileSize($filename) {

lib/public/Files/Storage.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function filetype($path);
135135
* The result for filesize when called on a folder is required to be 0
136136
*
137137
* @param string $path
138-
* @return int|bool
138+
* @return int|float|bool
139139
* @since 6.0.0
140140
*/
141141
public function filesize($path);
@@ -227,7 +227,7 @@ public function file_get_contents($path);
227227
*
228228
* @param string $path
229229
* @param mixed $data
230-
* @return int|false
230+
* @return int|float|false
231231
* @since 6.0.0
232232
*/
233233
public function file_put_contents($path, $data);
@@ -296,7 +296,7 @@ public function hash($type, $path, $raw = false);
296296
* see https://www.php.net/manual/en/function.free_space.php
297297
*
298298
* @param string $path
299-
* @return int|bool
299+
* @return int|float|bool
300300
* @since 6.0.0
301301
*/
302302
public function free_space($path);

lib/public/Files/Storage/IStorage.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function filetype($path);
132132
* The result for filesize when called on a folder is required to be 0
133133
*
134134
* @param string $path
135-
* @return int|bool
135+
* @return int|float|bool
136136
* @since 9.0.0
137137
*/
138138
public function filesize($path);
@@ -224,7 +224,7 @@ public function file_get_contents($path);
224224
*
225225
* @param string $path
226226
* @param mixed $data
227-
* @return int|false
227+
* @return int|float|false
228228
* @since 9.0.0
229229
*/
230230
public function file_put_contents($path, $data);
@@ -293,7 +293,7 @@ public function hash($type, $path, $raw = false);
293293
* see https://www.php.net/manual/en/function.free_space.php
294294
*
295295
* @param string $path
296-
* @return int|bool
296+
* @return int|float|bool
297297
* @since 9.0.0
298298
*/
299299
public function free_space($path);

0 commit comments

Comments
 (0)