Skip to content

Commit 6e7094b

Browse files
authored
Merge pull request #29426 from nextcloud/backport-icewind-streams-extra-fixes-for-0.7.2
Extra fixes needed for icewind/streams update to 0.7.2
2 parents ea92f78 + 80dca60 commit 6e7094b

16 files changed

Lines changed: 115 additions & 89 deletions

File tree

apps/dav/lib/Connector/Sabre/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ public function getContentType() {
494494
}
495495

496496
/**
497-
* @return array|false
497+
* @return array|bool
498498
*/
499499
public function getDirectDownload() {
500500
if (\OCP\App::isEnabled('encryption')) {

apps/files_external/lib/Lib/Storage/SMB.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ public function hasUpdated($path, $time) {
446446
/**
447447
* @param string $path
448448
* @param string $mode
449-
* @return resource|false
449+
* @return resource|bool
450450
*/
451451
public function fopen($path, $mode) {
452452
$fullPath = $this->buildPath($path);
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
[]
1+
{
2+
"packages": [],
3+
"dev": false,
4+
"dev-package-names": []
5+
}

lib/private/Files/ObjectStore/StorageObjectStore.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
use OCP\Files\ObjectStore\IObjectStore;
2828
use OCP\Files\Storage\IStorage;
29+
use function is_resource;
2930

3031
/**
3132
* Object store that wraps a storage backend, mostly for testing purposes
@@ -57,11 +58,11 @@ public function getStorageId() {
5758
*/
5859
public function readObject($urn) {
5960
$handle = $this->storage->fopen($urn, 'r');
60-
if ($handle) {
61+
if (is_resource($handle)) {
6162
return $handle;
62-
} else {
63-
throw new \Exception();
6463
}
64+
65+
throw new \Exception();
6566
}
6667

6768
/**

lib/private/Files/SimpleFS/NewSimpleFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public function read() {
208208
/**
209209
* Open the file as stream for writing, resulting resource can be operated as stream like the result from php's own fopen
210210
*
211-
* @return resource
211+
* @return resource|bool
212212
* @throws \OCP\Files\NotPermittedException
213213
* @since 14.0.0
214214
*/

lib/private/Files/Storage/Common.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,9 @@ public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t
631631
}
632632
}
633633

634-
if ($result and $preserveMtime) {
635-
$this->touch($targetInternalPath, $sourceStorage->filemtime($sourceInternalPath));
634+
if ($result && $preserveMtime) {
635+
$mtime = $sourceStorage->filemtime($sourceInternalPath);
636+
$this->touch($targetInternalPath, is_int($mtime) ? $mtime : null);
636637
}
637638

638639
if (!$result) {

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function rmdir($path) {
156156
* see http://php.net/manual/en/function.opendir.php
157157
*
158158
* @param string $path
159-
* @return resource
159+
* @return resource|bool
160160
*/
161161
public function opendir($path) {
162162
return $this->storage->opendir($this->findPathToUse($path));
@@ -187,7 +187,7 @@ public function is_file($path) {
187187
* only the following keys are required in the result: size and mtime
188188
*
189189
* @param string $path
190-
* @return array
190+
* @return array|bool
191191
*/
192192
public function stat($path) {
193193
return $this->storage->stat($this->findPathToUse($path));
@@ -197,7 +197,7 @@ public function stat($path) {
197197
* see http://php.net/manual/en/function.filetype.php
198198
*
199199
* @param string $path
200-
* @return bool
200+
* @return string|bool
201201
*/
202202
public function filetype($path) {
203203
return $this->storage->filetype($this->findPathToUse($path));
@@ -208,7 +208,7 @@ public function filetype($path) {
208208
* The result for filesize when called on a folder is required to be 0
209209
*
210210
* @param string $path
211-
* @return int
211+
* @return int|bool
212212
*/
213213
public function filesize($path) {
214214
return $this->storage->filesize($this->findPathToUse($path));
@@ -289,7 +289,7 @@ public function file_exists($path) {
289289
* see http://php.net/manual/en/function.filemtime.php
290290
*
291291
* @param string $path
292-
* @return int
292+
* @return int|bool
293293
*/
294294
public function filemtime($path) {
295295
return $this->storage->filemtime($this->findPathToUse($path));
@@ -299,7 +299,7 @@ public function filemtime($path) {
299299
* see http://php.net/manual/en/function.file_get_contents.php
300300
*
301301
* @param string $path
302-
* @return string
302+
* @return string|bool
303303
*/
304304
public function file_get_contents($path) {
305305
return $this->storage->file_get_contents($this->findPathToUse($path));
@@ -358,7 +358,7 @@ public function copy($path1, $path2) {
358358
*
359359
* @param string $path
360360
* @param string $mode
361-
* @return resource
361+
* @return resource|bool
362362
*/
363363
public function fopen($path, $mode) {
364364
$result = $this->storage->fopen($this->findPathToUse($path), $mode);
@@ -373,7 +373,7 @@ public function fopen($path, $mode) {
373373
* The mimetype for a folder is required to be "httpd/unix-directory"
374374
*
375375
* @param string $path
376-
* @return string
376+
* @return string|bool
377377
*/
378378
public function getMimeType($path) {
379379
return $this->storage->getMimeType($this->findPathToUse($path));
@@ -385,7 +385,7 @@ public function getMimeType($path) {
385385
* @param string $type
386386
* @param string $path
387387
* @param bool $raw
388-
* @return string
388+
* @return string|bool
389389
*/
390390
public function hash($type, $path, $raw = false) {
391391
return $this->storage->hash($type, $this->findPathToUse($path), $raw);
@@ -395,7 +395,7 @@ public function hash($type, $path, $raw = false) {
395395
* see http://php.net/manual/en/function.free_space.php
396396
*
397397
* @param string $path
398-
* @return int
398+
* @return int|bool
399399
*/
400400
public function free_space($path) {
401401
return $this->storage->free_space($this->findPathToUse($path));
@@ -405,7 +405,7 @@ public function free_space($path) {
405405
* search for occurrences of $query in file names
406406
*
407407
* @param string $query
408-
* @return array
408+
* @return array|bool
409409
*/
410410
public function search($query) {
411411
return $this->storage->search($query);
@@ -428,7 +428,7 @@ public function touch($path, $mtime = null) {
428428
* The local version of the file can be temporary and doesn't have to be persistent across requests
429429
*
430430
* @param string $path
431-
* @return string
431+
* @return string|bool
432432
*/
433433
public function getLocalFile($path) {
434434
return $this->storage->getLocalFile($this->findPathToUse($path));
@@ -480,7 +480,7 @@ public function getScanner($path = '', $storage = null) {
480480
* get the ETag for a file or folder
481481
*
482482
* @param string $path
483-
* @return string
483+
* @return string|bool
484484
*/
485485
public function getETag($path) {
486486
return $this->storage->getETag($this->findPathToUse($path));

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function rmdir($path) {
106106
* see http://php.net/manual/en/function.opendir.php
107107
*
108108
* @param string $path
109-
* @return resource
109+
* @return resource|bool
110110
*/
111111
public function opendir($path) {
112112
return $this->getWrapperStorage()->opendir($this->getUnjailedPath($path));
@@ -137,7 +137,7 @@ public function is_file($path) {
137137
* only the following keys are required in the result: size and mtime
138138
*
139139
* @param string $path
140-
* @return array
140+
* @return array|bool
141141
*/
142142
public function stat($path) {
143143
return $this->getWrapperStorage()->stat($this->getUnjailedPath($path));
@@ -158,7 +158,7 @@ public function filetype($path) {
158158
* The result for filesize when called on a folder is required to be 0
159159
*
160160
* @param string $path
161-
* @return int
161+
* @return int|bool
162162
*/
163163
public function filesize($path) {
164164
return $this->getWrapperStorage()->filesize($this->getUnjailedPath($path));
@@ -239,7 +239,7 @@ public function file_exists($path) {
239239
* see http://php.net/manual/en/function.filemtime.php
240240
*
241241
* @param string $path
242-
* @return int
242+
* @return int|bool
243243
*/
244244
public function filemtime($path) {
245245
return $this->getWrapperStorage()->filemtime($this->getUnjailedPath($path));
@@ -249,7 +249,7 @@ public function filemtime($path) {
249249
* see http://php.net/manual/en/function.file_get_contents.php
250250
*
251251
* @param string $path
252-
* @return string
252+
* @return string|bool
253253
*/
254254
public function file_get_contents($path) {
255255
return $this->getWrapperStorage()->file_get_contents($this->getUnjailedPath($path));
@@ -303,7 +303,7 @@ public function copy($path1, $path2) {
303303
*
304304
* @param string $path
305305
* @param string $mode
306-
* @return resource
306+
* @return resource|bool
307307
*/
308308
public function fopen($path, $mode) {
309309
return $this->getWrapperStorage()->fopen($this->getUnjailedPath($path), $mode);
@@ -314,7 +314,7 @@ public function fopen($path, $mode) {
314314
* The mimetype for a folder is required to be "httpd/unix-directory"
315315
*
316316
* @param string $path
317-
* @return string
317+
* @return string|bool
318318
*/
319319
public function getMimeType($path) {
320320
return $this->getWrapperStorage()->getMimeType($this->getUnjailedPath($path));
@@ -326,7 +326,7 @@ public function getMimeType($path) {
326326
* @param string $type
327327
* @param string $path
328328
* @param bool $raw
329-
* @return string
329+
* @return string|bool
330330
*/
331331
public function hash($type, $path, $raw = false) {
332332
return $this->getWrapperStorage()->hash($type, $this->getUnjailedPath($path), $raw);
@@ -336,7 +336,7 @@ public function hash($type, $path, $raw = false) {
336336
* see http://php.net/manual/en/function.free_space.php
337337
*
338338
* @param string $path
339-
* @return int
339+
* @return int|bool
340340
*/
341341
public function free_space($path) {
342342
return $this->getWrapperStorage()->free_space($this->getUnjailedPath($path));
@@ -346,7 +346,7 @@ public function free_space($path) {
346346
* search for occurrences of $query in file names
347347
*
348348
* @param string $query
349-
* @return array
349+
* @return array|bool
350350
*/
351351
public function search($query) {
352352
return $this->getWrapperStorage()->search($query);
@@ -369,7 +369,7 @@ public function touch($path, $mtime = null) {
369369
* The local version of the file can be temporary and doesn't have to be persistent across requests
370370
*
371371
* @param string $path
372-
* @return string
372+
* @return string|bool
373373
*/
374374
public function getLocalFile($path) {
375375
return $this->getWrapperStorage()->getLocalFile($this->getUnjailedPath($path));
@@ -432,7 +432,7 @@ public function getWatcher($path = '', $storage = null) {
432432
* get the ETag for a file or folder
433433
*
434434
* @param string $path
435-
* @return string
435+
* @return string|bool
436436
*/
437437
public function getETag($path) {
438438
return $this->getWrapperStorage()->getETag($this->getUnjailedPath($path));

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ protected function getSize($path, $storage = null) {
9494
* Get free space as limited by the quota
9595
*
9696
* @param string $path
97-
* @return int
97+
* @return int|bool
9898
*/
9999
public function free_space($path) {
100100
if ($this->quota < 0 || strpos($path, 'cache') === 0 || strpos($path, 'uploads') === 0) {
@@ -154,15 +154,15 @@ public function copy($source, $target) {
154154
*
155155
* @param string $path
156156
* @param string $mode
157-
* @return resource
157+
* @return resource|bool
158158
*/
159159
public function fopen($path, $mode) {
160160
$source = $this->storage->fopen($path, $mode);
161161

162162
// don't apply quota for part files
163163
if (!$this->isPartFile($path)) {
164164
$free = $this->free_space($path);
165-
if ($source && $free >= 0 && $mode !== 'r' && $mode !== 'rb') {
165+
if ($source && is_int($free) && $free >= 0 && $mode !== 'r' && $mode !== 'rb') {
166166
// only apply quota for files, not metadata, trash or others
167167
if ($this->shouldApplyQuota($path)) {
168168
return \OC\Files\Stream\Quota::wrap($source, $free);

0 commit comments

Comments
 (0)