1
0
Fork 0
mirror of synced 2024-09-30 17:26:48 +13:00

make comparisons strict

This commit is contained in:
Damodar Lohani 2021-12-07 13:15:39 +05:45
parent ce337cff32
commit b4c3802558

View file

@ -581,7 +581,7 @@ App::post('/v1/storage/buckets/:bucketId/files')
$size = (\is_array($file['size']) && isset($file['size'][0])) ? $file['size'][0] : $file['size'];
$contentRange = $request->getHeader('content-range');
$fileId = $fileId == 'unique()' ? $dbForInternal->getId() : $fileId;
$fileId = $fileId === 'unique()' ? $dbForInternal->getId() : $fileId;
$chunk = 1;
$chunks = 1;
@ -594,7 +594,7 @@ App::post('/v1/storage/buckets/:bucketId/files')
throw new Exception('Invalid content-range header', 400);
}
if ($end == $size) {
if ($end === $size) {
//if it's a last chunks the chunk size might differ, so we set the $chunks and $chunk to notify it's last chunk
$chunks = $chunk = -1;
} else {
@ -622,13 +622,13 @@ App::post('/v1/storage/buckets/:bucketId/files')
// Save to storage
$size ??= $device->getFileSize($fileTmpName);
$path = $device->getPath($fileId . '.' . \pathinfo($fileName, PATHINFO_EXTENSION));
$path = str_ireplace($device->getRoot(), $device->getRoot() . DIRECTORY_SEPARATOR . $bucket->getId(), $path);
$path = str_ireplace($device->getRoot(), $device->getRoot() . DIRECTORY_SEPARATOR . $bucket->getId(), $path); // Add bucket id to path after root
$file = $dbForInternal->getDocument('bucket_' . $bucketId, $fileId);
if (!$file->isEmpty()) {
$chunks = $file->getAttribute('chunksTotal', 1);
if ($chunk == -1) {
if ($chunk === -1) {
$chunk = $chunks;
}
}
@ -640,7 +640,7 @@ App::post('/v1/storage/buckets/:bucketId/files')
$read = (is_null($read) && !$user->isEmpty()) ? ['user:' . $user->getId()] : $read ?? [];
$write = (is_null($write) && !$user->isEmpty()) ? ['user:' . $user->getId()] : $write ?? [];
if ($chunksUploaded == $chunks) {
if ($chunksUploaded === $chunks) {
if (App::getEnv('_APP_STORAGE_ANTIVIRUS') === 'enabled' && $bucket->getAttribute('antiVirus', true) && $size <= APP_LIMIT_ANTIVIRUS) {
$antiVirus = new Network(App::getEnv('_APP_STORAGE_ANTIVIRUS_HOST', 'clamav'),
(int) App::getEnv('_APP_STORAGE_ANTIVIRUS_PORT', 3310));