Skip to content
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
3 changes: 2 additions & 1 deletion .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ config = {
"cliEncryption",
],
"extraApps": {
"encryption": "composer install",
"encryption": "git checkout v1.5.3; composer install",
},
"testingRemoteSystem": False,
"extraSetup": [{
Expand All @@ -294,6 +294,7 @@ config = {
"commands": [
"php occ maintenance:singleuser --on",
"php occ encryption:enable",
"php occ app:list encryption",
"php occ encryption:select-encryption-type masterkey --yes",
"php occ encryption:encrypt-all --yes",
"php occ encryption:status",
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public function setETag($etag) {
* size because the actual size value isn't returned by google. This function
* will return null in this case)
*
* @return integer|null
* @return integer|float|null
*/
public function getSize() {
$size = $this->info->getSize();
Expand Down
35 changes: 15 additions & 20 deletions apps/dav/lib/Connector/Sabre/QuotaPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ public function handleBeforeCreateFile($uri, $data, $parent, $modified) {
* This method is called before any HTTP method and validates there is enough free space to store the file
*
* @param string $path path of the user's home
* @param int $length size to check whether it fits
* @param int $extraSpace additional space granted, usually used when overwriting files
* @param int|float $length size to check whether it fits
* @param int|float $extraSpace additional space granted, usually used when overwriting files
* @throws InsufficientStorage
* @return bool
*/
Expand All @@ -204,25 +204,20 @@ public function checkQuota($path, $length = null, $extraSpace = 0) {
$path = \rtrim($parentPath, '/') . '/' . $info['name'];
}
$freeSpace = $this->getFreeSpace($path);
// workaround to guarantee compatibility on 32-bit systems as otherwise this would cause an int overflow on such systems
// when $freeSpace is above the max supported value. $freeSpace should be a float so we are using the <= 0.0 comparison
if (PHP_INT_SIZE === 4) {
$availableSpace = $freeSpace + $extraSpace;
if ($freeSpace !== FileInfo::SPACE_UNKNOWN && $freeSpace !== FileInfo::SPACE_UNLIMITED && (($length > $availableSpace) || ($availableSpace <= 0.0))) {
if (isset($chunkHandler)) {
$chunkHandler->cleanup();
}
throw new InsufficientStorage();
}
} else {
// freeSpace might be false, or an int. Anyway, make sure that availableSpace will be an int.
$availableSpace = (int) $freeSpace + $extraSpace;
if ($freeSpace !== FileInfo::SPACE_UNKNOWN && $freeSpace !== FileInfo::SPACE_UNLIMITED && (($length > $availableSpace) || ($availableSpace === 0))) {
if (isset($chunkHandler)) {
$chunkHandler->cleanup();
}
throw new InsufficientStorage();
if ($freeSpace === false) {
$freeSpace = 0;
}
// There could be cases where both $freeSpace and $extraSpace are floats:
// * $freeSpace could come from local storage, which calls disk_free_space, which returns float
// * $extraSpace could come from the DB. "size" column is bigint, which is returned as string. The storage
// cache uses `0 + $data['size']` where the $data['size'] should be a string, which should return an int if
// the result fits inside, but it could also be a float if it doesn't (more likely in 32 bits)
$availableSpace = $freeSpace + $extraSpace;
if ($freeSpace !== FileInfo::SPACE_UNKNOWN && $freeSpace !== FileInfo::SPACE_UNLIMITED && (($length > $availableSpace) || ($availableSpace <= 0.0))) {
if (isset($chunkHandler)) {
$chunkHandler->cleanup();
}
throw new InsufficientStorage();
}
}
return true;
Expand Down
1 change: 1 addition & 0 deletions apps/dav/lib/Upload/ChunkingPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ private function verifySize() {
return;
}
$actualSize = $this->sourceNode->getSize();
// $actualSize could be either an int or a float
if ($expectedSize != $actualSize) {
throw new BadRequest("Chunks on server do not sum up to $expectedSize but to $actualSize");
}
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/FileInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function getEtag() {
}

/**
* @return int
* @return int|float
*/
public function getSize() {
return isset($this->data['size']) ? $this->data['size'] : 0;
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/Node/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public function getMTime() {
}

/**
* @return int
* @return int|float
* @throws InvalidPathException
* @throws NotFoundException
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/Storage/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public function getMTime() {
/**
* Get the size of the file or folder in bytes
*
* @return int
* @return int|float
* @throws \OCP\Files\StorageNotAvailableException
*/
public function getSize() {
Expand Down
5 changes: 4 additions & 1 deletion lib/public/Files/Cache/ICacheEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ public function getMimePart();
/**
* Get the file size in bytes
*
* @return int
* It should return the size as integer, but it could return it
* as float if the size doesn't fit
*
* @return int|float
* @since 9.0.0
*/
public function getSize();
Expand Down
2 changes: 1 addition & 1 deletion lib/public/Files/FileInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function getEtag();
/**
* Get the size in bytes for the file or folder
*
* @return int
* @return int|foat
* @since 7.0.0
*/
public function getSize();
Expand Down
5 changes: 4 additions & 1 deletion lib/public/Files/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ public function getMTime();
/**
* Get the size of the file or folder in bytes
*
* @return int
* An integer should be returned. A float can also be returned,
* usually if the size doesn't fit in an integer
*
* @return int|float
* @throws InvalidPathException
* @throws NotFoundException
* @since 6.0.0
Expand Down
7 changes: 6 additions & 1 deletion lib/public/Files/Storage/IStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,13 @@ public function hash($type, $path, $raw = false);
/**
* see http://php.net/manual/en/function.free_space.php
*
* This method should return an int if possible. If the free space doesn't fit in
* an integer, a float can be used instead
* The local storage implementation uses the disk_free_space function, which returns
* a float.
*
* @param string $path
* @return int|false
* @return int|float|false
* @throws StorageNotAvailableException if the storage is temporarily not available
* @since 9.0.0
*/
Expand Down