Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra fixes needed for icewind/streams update to 0.7.2 #29426

Merged
merged 1 commit into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ public function getContentType() {
}

/**
* @return array|false
* @return array|bool
*/
public function getDirectDownload() {
if (\OCP\App::isEnabled('encryption')) {
Expand Down
2 changes: 1 addition & 1 deletion apps/files_external/lib/Lib/Storage/SMB.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ public function hasUpdated($path, $time) {
/**
* @param string $path
* @param string $mode
* @return resource|false
* @return resource|bool
*/
public function fopen($path, $mode) {
$fullPath = $this->buildPath($path);
Expand Down
6 changes: 5 additions & 1 deletion lib/composer/composer/installed.json
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
[]
{
"packages": [],
"dev": false,
"dev-package-names": []
}
7 changes: 4 additions & 3 deletions lib/private/Files/ObjectStore/StorageObjectStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

use OCP\Files\ObjectStore\IObjectStore;
use OCP\Files\Storage\IStorage;
use function is_resource;

/**
* Object store that wraps a storage backend, mostly for testing purposes
Expand Down Expand Up @@ -57,11 +58,11 @@ public function getStorageId() {
*/
public function readObject($urn) {
$handle = $this->storage->fopen($urn, 'r');
if ($handle) {
if (is_resource($handle)) {
return $handle;
} else {
throw new \Exception();
}

throw new \Exception();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/SimpleFS/NewSimpleFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public function read() {
/**
* Open the file as stream for writing, resulting resource can be operated as stream like the result from php's own fopen
*
* @return resource
* @return resource|bool
* @throws \OCP\Files\NotPermittedException
* @since 14.0.0
*/
Expand Down
5 changes: 3 additions & 2 deletions lib/private/Files/Storage/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,9 @@ public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t
}
}

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

if (!$result) {
Expand Down
26 changes: 13 additions & 13 deletions lib/private/Files/Storage/Wrapper/Encoding.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function rmdir($path) {
* see http://php.net/manual/en/function.opendir.php
*
* @param string $path
* @return resource
* @return resource|bool
*/
public function opendir($path) {
return $this->storage->opendir($this->findPathToUse($path));
Expand Down Expand Up @@ -187,7 +187,7 @@ public function is_file($path) {
* only the following keys are required in the result: size and mtime
*
* @param string $path
* @return array
* @return array|bool
*/
public function stat($path) {
return $this->storage->stat($this->findPathToUse($path));
Expand All @@ -197,7 +197,7 @@ public function stat($path) {
* see http://php.net/manual/en/function.filetype.php
*
* @param string $path
* @return bool
* @return string|bool
*/
public function filetype($path) {
return $this->storage->filetype($this->findPathToUse($path));
Expand All @@ -208,7 +208,7 @@ public function filetype($path) {
* The result for filesize when called on a folder is required to be 0
*
* @param string $path
* @return int
* @return int|bool
*/
public function filesize($path) {
return $this->storage->filesize($this->findPathToUse($path));
Expand Down Expand Up @@ -289,7 +289,7 @@ public function file_exists($path) {
* see http://php.net/manual/en/function.filemtime.php
*
* @param string $path
* @return int
* @return int|bool
*/
public function filemtime($path) {
return $this->storage->filemtime($this->findPathToUse($path));
Expand All @@ -299,7 +299,7 @@ public function filemtime($path) {
* see http://php.net/manual/en/function.file_get_contents.php
*
* @param string $path
* @return string
* @return string|bool
*/
public function file_get_contents($path) {
return $this->storage->file_get_contents($this->findPathToUse($path));
Expand Down Expand Up @@ -358,7 +358,7 @@ public function copy($path1, $path2) {
*
* @param string $path
* @param string $mode
* @return resource
* @return resource|bool
*/
public function fopen($path, $mode) {
$result = $this->storage->fopen($this->findPathToUse($path), $mode);
Expand All @@ -373,7 +373,7 @@ public function fopen($path, $mode) {
* The mimetype for a folder is required to be "httpd/unix-directory"
*
* @param string $path
* @return string
* @return string|bool
*/
public function getMimeType($path) {
return $this->storage->getMimeType($this->findPathToUse($path));
Expand All @@ -385,7 +385,7 @@ public function getMimeType($path) {
* @param string $type
* @param string $path
* @param bool $raw
* @return string
* @return string|bool
*/
public function hash($type, $path, $raw = false) {
return $this->storage->hash($type, $this->findPathToUse($path), $raw);
Expand All @@ -395,7 +395,7 @@ public function hash($type, $path, $raw = false) {
* see http://php.net/manual/en/function.free_space.php
*
* @param string $path
* @return int
* @return int|bool
*/
public function free_space($path) {
return $this->storage->free_space($this->findPathToUse($path));
Expand All @@ -405,7 +405,7 @@ public function free_space($path) {
* search for occurrences of $query in file names
*
* @param string $query
* @return array
* @return array|bool
*/
public function search($query) {
return $this->storage->search($query);
Expand All @@ -428,7 +428,7 @@ public function touch($path, $mtime = null) {
* The local version of the file can be temporary and doesn't have to be persistent across requests
*
* @param string $path
* @return string
* @return string|bool
*/
public function getLocalFile($path) {
return $this->storage->getLocalFile($this->findPathToUse($path));
Expand Down Expand Up @@ -480,7 +480,7 @@ public function getScanner($path = '', $storage = null) {
* get the ETag for a file or folder
*
* @param string $path
* @return string
* @return string|bool
*/
public function getETag($path) {
return $this->storage->getETag($this->findPathToUse($path));
Expand Down
24 changes: 12 additions & 12 deletions lib/private/Files/Storage/Wrapper/Jail.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function rmdir($path) {
* see http://php.net/manual/en/function.opendir.php
*
* @param string $path
* @return resource
* @return resource|bool
*/
public function opendir($path) {
return $this->getWrapperStorage()->opendir($this->getUnjailedPath($path));
Expand Down Expand Up @@ -137,7 +137,7 @@ public function is_file($path) {
* only the following keys are required in the result: size and mtime
*
* @param string $path
* @return array
* @return array|bool
*/
public function stat($path) {
return $this->getWrapperStorage()->stat($this->getUnjailedPath($path));
Expand All @@ -158,7 +158,7 @@ public function filetype($path) {
* The result for filesize when called on a folder is required to be 0
*
* @param string $path
* @return int
* @return int|bool
*/
public function filesize($path) {
return $this->getWrapperStorage()->filesize($this->getUnjailedPath($path));
Expand Down Expand Up @@ -239,7 +239,7 @@ public function file_exists($path) {
* see http://php.net/manual/en/function.filemtime.php
*
* @param string $path
* @return int
* @return int|bool
*/
public function filemtime($path) {
return $this->getWrapperStorage()->filemtime($this->getUnjailedPath($path));
Expand All @@ -249,7 +249,7 @@ public function filemtime($path) {
* see http://php.net/manual/en/function.file_get_contents.php
*
* @param string $path
* @return string
* @return string|bool
*/
public function file_get_contents($path) {
return $this->getWrapperStorage()->file_get_contents($this->getUnjailedPath($path));
Expand Down Expand Up @@ -303,7 +303,7 @@ public function copy($path1, $path2) {
*
* @param string $path
* @param string $mode
* @return resource
* @return resource|bool
*/
public function fopen($path, $mode) {
return $this->getWrapperStorage()->fopen($this->getUnjailedPath($path), $mode);
Expand All @@ -314,7 +314,7 @@ public function fopen($path, $mode) {
* The mimetype for a folder is required to be "httpd/unix-directory"
*
* @param string $path
* @return string
* @return string|bool
*/
public function getMimeType($path) {
return $this->getWrapperStorage()->getMimeType($this->getUnjailedPath($path));
Expand All @@ -326,7 +326,7 @@ public function getMimeType($path) {
* @param string $type
* @param string $path
* @param bool $raw
* @return string
* @return string|bool
*/
public function hash($type, $path, $raw = false) {
return $this->getWrapperStorage()->hash($type, $this->getUnjailedPath($path), $raw);
Expand All @@ -336,7 +336,7 @@ public function hash($type, $path, $raw = false) {
* see http://php.net/manual/en/function.free_space.php
*
* @param string $path
* @return int
* @return int|bool
*/
public function free_space($path) {
return $this->getWrapperStorage()->free_space($this->getUnjailedPath($path));
Expand All @@ -346,7 +346,7 @@ public function free_space($path) {
* search for occurrences of $query in file names
*
* @param string $query
* @return array
* @return array|bool
*/
public function search($query) {
return $this->getWrapperStorage()->search($query);
Expand All @@ -369,7 +369,7 @@ public function touch($path, $mtime = null) {
* The local version of the file can be temporary and doesn't have to be persistent across requests
*
* @param string $path
* @return string
* @return string|bool
*/
public function getLocalFile($path) {
return $this->getWrapperStorage()->getLocalFile($this->getUnjailedPath($path));
Expand Down Expand Up @@ -432,7 +432,7 @@ public function getWatcher($path = '', $storage = null) {
* get the ETag for a file or folder
*
* @param string $path
* @return string
* @return string|bool
*/
public function getETag($path) {
return $this->getWrapperStorage()->getETag($this->getUnjailedPath($path));
Expand Down
6 changes: 3 additions & 3 deletions lib/private/Files/Storage/Wrapper/Quota.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected function getSize($path, $storage = null) {
* Get free space as limited by the quota
*
* @param string $path
* @return int
* @return int|bool
*/
public function free_space($path) {
if ($this->quota < 0 || strpos($path, 'cache') === 0 || strpos($path, 'uploads') === 0) {
Expand Down Expand Up @@ -154,15 +154,15 @@ public function copy($source, $target) {
*
* @param string $path
* @param string $mode
* @return resource
* @return resource|bool
*/
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($path);
if ($source && $free >= 0 && $mode !== 'r' && $mode !== 'rb') {
if ($source && is_int($free) && $free >= 0 && $mode !== 'r' && $mode !== 'rb') {
// only apply quota for files, not metadata, trash or others
if ($this->shouldApplyQuota($path)) {
return \OC\Files\Stream\Quota::wrap($source, $free);
Expand Down
Loading