From 8b878a8be76ef1b70188adde29fbea846b7c7079 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 14 Mar 2022 07:17:33 +0000 Subject: [PATCH 001/117] basic definition --- src/Storage/Device.php | 11 +++++++++++ src/Storage/Device/S3.php | 13 +++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/Storage/Device.php b/src/Storage/Device.php index 619e401a..dbecf142 100644 --- a/src/Storage/Device.php +++ b/src/Storage/Device.php @@ -84,6 +84,17 @@ abstract public function abort(string $path, string $extra = ''): bool; */ abstract public function read(string $path, int $offset = 0, int $length = null): string; + /** + * Transfer + * + * @param string $path + * @param string $destination + * @param Device $device + * + * @return string + */ + abstract public function transfer(string $path, string $destination, Device $device): bool; + /** * Write file by given path. * diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 1da94e98..afdec806 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -201,6 +201,19 @@ public function upload(string $source, string $path, int $chunk = 1, int $chunks return $metadata['chunks']; } + /** + * Transfer + * + * @param string $path + * @param string $destination + * @param Device $device + * + * @return string + */ + abstract public function transfer(string $path, string $destination, Device $device): bool { + + } + /** * Start Multipart Upload * From 6fe6ef0a436917696a227cc87a7e5d81e08f0554 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 15 Mar 2022 08:06:05 +0000 Subject: [PATCH 002/117] transfer functionality implementation --- src/Storage/Device.php | 25 +++++++++++++++++++++++++ src/Storage/Device/Local.php | 29 +++++++++++++++++++++++++++++ src/Storage/Device/S3.php | 21 +++++++++++++++++++-- 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/src/Storage/Device.php b/src/Storage/Device.php index dbecf142..3ab90d08 100644 --- a/src/Storage/Device.php +++ b/src/Storage/Device.php @@ -6,6 +6,31 @@ abstract class Device { + + /** + * Max chunk size while transfering file from one device to another + */ + protected int $transferChunkSize = 20000000; //20 MB + + /** + * Set Transfer Chunk Size + * + * @param int $chunkSize + * @return void + */ + public function setTransferChunkSize(int $chunkSize): void { + $this->transferChunkSize = $chunkSize; + } + + /** + * Get Transfer Chunk Size + * + * @return int + */ + public function getTransferChunkSize(): int { + return $this->transferChunkSize; + } + /** * Get Name. * diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index eed91cf9..87842fdf 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -137,6 +137,35 @@ public function upload(string $source, string $path, int $chunk = 1, int $chunks return $chunksReceived; } + /** + * Transfer + * + * @param string $path + * @param string $destination + * @param Device $device + * + * @return string + */ + public function transfer(string $path, string $destination, Device $device): bool { + $size = $this->getFileSize($path); + $contentType = $this->getFileMimeType($path); + + if($size <= $this->transferChunkSize) { + $source = $this->read($path); + return $device->write($destination, $source, $contentType); + } + + $totalChunks = \ceil($size / $this->transferChunkSize); + $counter = 0; + $metadata = ['content_type' => $contentType]; + for($counter; $counter < $totalChunks; $counter++) { + $start = $counter * $this->transferChunkSize; + $data = $this->read($path, $start, $this->transferChunkSize); + $device->upload($data, $destination, $counter+1, $totalChunks, $metadata); + } + return true; + } + /** * Abort Chunked Upload * diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index afdec806..61821cfa 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -210,8 +210,25 @@ public function upload(string $source, string $path, int $chunk = 1, int $chunks * * @return string */ - abstract public function transfer(string $path, string $destination, Device $device): bool { - + public function transfer(string $path, string $destination, Device $device): bool { + $response = $this->getInfo($path); + $size = (int)($response['content-length'] ?? 0); + $contentType = $response['content-type'] ?? ''; + + if($size <= $this->transferChunkSize) { + $source = $this->read($path); + return $device->write($destination, $source, $contentType); + } + + $totalChunks = \ceil($size / $this->transferChunkSize); + $counter = 0; + $metadata = ['content_type' => $contentType]; + for($counter; $counter < $totalChunks; $counter++) { + $start = $counter * $this->transferChunkSize; + $data = $this->read($path, $start, $this->transferChunkSize); + $device->upload($data, $destination, $counter+1, $totalChunks, $metadata); + } + return true; } /** From 238e13215180dba0eeb58b658b75fcf115606355 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 15 Mar 2022 08:41:58 +0000 Subject: [PATCH 003/117] update move to use transfer to make it efficient for larger size --- src/Storage/Device/S3.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 61821cfa..4943132e 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -392,13 +392,7 @@ public function write(string $path, string $data, string $contentType = ''): boo */ public function move(string $source, string $target): bool { - $type = $this->getFileMimeType($source); - - if ($this->write($target, $this->read($source), $type)) { - $this->delete($source); - } - - return true; + return $this->transfer($source, $target, $this); } /** From 89b130dacbc367d70ba03be839332b92707432a2 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 15 Mar 2022 10:30:56 +0000 Subject: [PATCH 004/117] fix and tests in local --- composer.lock | 394 +++++++++++++++-------------- src/Storage/Device/Local.php | 5 +- src/Storage/Device/S3.php | 6 +- tests/Storage/Device/LocalTest.php | 24 +- 4 files changed, 230 insertions(+), 199 deletions(-) diff --git a/composer.lock b/composer.lock index 6f813ef2..497f3899 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "124a0248853b18b623e8a315d291e9c0", + "content-hash": "1df212eaa94b7c555a893db0225a179b", "packages": [ { "name": "utopia-php/framework", - "version": "0.19.2", + "version": "0.19.7", "source": { "type": "git", "url": "https://github.com/utopia-php/framework.git", - "reference": "49e4374b97c0f4d14bc84b424bdc9c3b7747e15f" + "reference": "f17afe77a21873b9be18ebc05283813468b4283a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/framework/zipball/49e4374b97c0f4d14bc84b424bdc9c3b7747e15f", - "reference": "49e4374b97c0f4d14bc84b424bdc9c3b7747e15f", + "url": "https://api.github.com/repos/utopia-php/framework/zipball/f17afe77a21873b9be18ebc05283813468b4283a", + "reference": "f17afe77a21873b9be18ebc05283813468b4283a", "shasum": "" }, "require": { @@ -51,9 +51,9 @@ ], "support": { "issues": "https://github.com/utopia-php/framework/issues", - "source": "https://github.com/utopia-php/framework/tree/0.19.2" + "source": "https://github.com/utopia-php/framework/tree/0.19.7" }, - "time": "2021-12-07T09:29:35+00:00" + "time": "2022-02-18T00:04:49+00:00" } ], "packages-dev": [ @@ -63,12 +63,12 @@ "source": { "type": "git", "url": "https://github.com/amphp/amp.git", - "reference": "591e06ec427c2d2e5018172552b9354c208419e7" + "reference": "9d5100cebffa729aaffecd3ad25dc5aeea4f13bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/amp/zipball/591e06ec427c2d2e5018172552b9354c208419e7", - "reference": "591e06ec427c2d2e5018172552b9354c208419e7", + "url": "https://api.github.com/repos/amphp/amp/zipball/9d5100cebffa729aaffecd3ad25dc5aeea4f13bb", + "reference": "9d5100cebffa729aaffecd3ad25dc5aeea4f13bb", "shasum": "" }, "require": { @@ -91,13 +91,13 @@ } }, "autoload": { - "psr-4": { - "Amp\\": "lib" - }, "files": [ "lib/functions.php", "lib/Internal/functions.php" - ] + ], + "psr-4": { + "Amp\\": "lib" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -137,7 +137,7 @@ "support": { "irc": "irc://irc.freenode.org/amphp", "issues": "https://github.com/amphp/amp/issues", - "source": "https://github.com/amphp/amp/tree/master" + "source": "https://github.com/amphp/amp/tree/v2.6.2" }, "funding": [ { @@ -145,7 +145,7 @@ "type": "github" } ], - "time": "2021-12-03T13:45:05+00:00" + "time": "2022-02-20T17:52:18+00:00" }, { "name": "amphp/byte-stream", @@ -181,12 +181,12 @@ } }, "autoload": { - "psr-4": { - "Amp\\ByteStream\\": "lib" - }, "files": [ "lib/functions.php" - ] + ], + "psr-4": { + "Amp\\ByteStream\\": "lib" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -231,12 +231,12 @@ "source": { "type": "git", "url": "https://github.com/composer/package-versions-deprecated.git", - "reference": "1927b0a81e48643ca45c4a55b34a7645b04f3acc" + "reference": "b4f54f74ef3453349c24a845d22392cd31e65f1d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/1927b0a81e48643ca45c4a55b34a7645b04f3acc", - "reference": "1927b0a81e48643ca45c4a55b34a7645b04f3acc", + "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/b4f54f74ef3453349c24a845d22392cd31e65f1d", + "reference": "b4f54f74ef3453349c24a845d22392cd31e65f1d", "shasum": "" }, "require": { @@ -281,7 +281,7 @@ "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", "support": { "issues": "https://github.com/composer/package-versions-deprecated/issues", - "source": "https://github.com/composer/package-versions-deprecated/tree/master" + "source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.5" }, "funding": [ { @@ -297,7 +297,7 @@ "type": "tidelift" } ], - "time": "2021-09-16T13:11:31+00:00" + "time": "2022-01-17T14:14:24+00:00" }, { "name": "composer/semver", @@ -305,19 +305,19 @@ "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "83e511e247de329283478496f7a1e114c9517506" + "reference": "f79c90ad4e9b41ac4dfc5d77bf398cf61fbd718b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/83e511e247de329283478496f7a1e114c9517506", - "reference": "83e511e247de329283478496f7a1e114c9517506", + "url": "https://api.github.com/repos/composer/semver/zipball/f79c90ad4e9b41ac4dfc5d77bf398cf61fbd718b", + "reference": "f79c90ad4e9b41ac4dfc5d77bf398cf61fbd718b", "shasum": "" }, "require": { "php": "^5.3.2 || ^7.0 || ^8.0" }, "require-dev": { - "phpstan/phpstan": "^0.12.54", + "phpstan/phpstan": "^1.4", "symfony/phpunit-bridge": "^4.2 || ^5" }, "default-branch": true, @@ -363,7 +363,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/semver/issues", - "source": "https://github.com/composer/semver/tree/3.2.6" + "source": "https://github.com/composer/semver/tree/3.3.0" }, "funding": [ { @@ -379,7 +379,7 @@ "type": "tidelift" } ], - "time": "2021-10-25T11:34:17+00:00" + "time": "2022-03-15T08:35:57+00:00" }, { "name": "composer/xdebug-handler", @@ -387,12 +387,12 @@ "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "f27e06cd9675801df441b3656569b328e04aa37c" + "reference": "dee81bf97571cb7168019825ee9522e8dc2a5936" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/f27e06cd9675801df441b3656569b328e04aa37c", - "reference": "f27e06cd9675801df441b3656569b328e04aa37c", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/dee81bf97571cb7168019825ee9522e8dc2a5936", + "reference": "dee81bf97571cb7168019825ee9522e8dc2a5936", "shasum": "" }, "require": { @@ -427,7 +427,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/1.4.6" + "source": "https://github.com/composer/xdebug-handler/tree/1.4" }, "funding": [ { @@ -443,7 +443,7 @@ "type": "tidelift" } ], - "time": "2021-03-25T17:01:18+00:00" + "time": "2022-01-05T14:26:21+00:00" }, { "name": "dnoegel/php-xdg-base-dir", @@ -488,25 +488,26 @@ "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "6410c4b8352cb64218641457cef64997e6b784fb" + "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/6410c4b8352cb64218641457cef64997e6b784fb", - "reference": "6410c4b8352cb64218641457cef64997e6b784fb", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc", + "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^8.0", + "doctrine/coding-standard": "^9", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.13 || 1.0.0-alpha2", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + "phpbench/phpbench": "^0.16 || ^1", + "phpstan/phpstan": "^1.4", + "phpstan/phpstan-phpunit": "^1", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "vimeo/psalm": "^4.22" }, "type": "library", "autoload": { @@ -549,7 +550,7 @@ "type": "tidelift" } ], - "time": "2020-11-10T19:05:51+00:00" + "time": "2022-03-03T08:28:38+00:00" }, { "name": "felixfbecker/advanced-json-rpc", @@ -602,12 +603,12 @@ "source": { "type": "git", "url": "https://github.com/felixfbecker/php-language-server-protocol.git", - "reference": "9d846d1f5cf101deee7a61c8ba7caa0a975cd730" + "reference": "6e82196ffd7c62f7794d778ca52b69feec9f2842" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/felixfbecker/php-language-server-protocol/zipball/9d846d1f5cf101deee7a61c8ba7caa0a975cd730", - "reference": "9d846d1f5cf101deee7a61c8ba7caa0a975cd730", + "url": "https://api.github.com/repos/felixfbecker/php-language-server-protocol/zipball/6e82196ffd7c62f7794d778ca52b69feec9f2842", + "reference": "6e82196ffd7c62f7794d778ca52b69feec9f2842", "shasum": "" }, "require": { @@ -649,9 +650,9 @@ ], "support": { "issues": "https://github.com/felixfbecker/php-language-server-protocol/issues", - "source": "https://github.com/felixfbecker/php-language-server-protocol/tree/1.5.1" + "source": "https://github.com/felixfbecker/php-language-server-protocol/tree/master" }, - "time": "2021-02-22T14:02:09+00:00" + "time": "2022-03-02T22:36:06+00:00" }, { "name": "myclabs/deep-copy", @@ -659,34 +660,35 @@ "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220" + "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220", - "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", + "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, - "replace": { - "myclabs/deep-copy": "self.version" + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3,<3.2.2" }, "require-dev": { - "doctrine/collections": "^1.0", - "doctrine/common": "^2.6", - "phpunit/phpunit": "^7.1" + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" }, "default-branch": true, "type": "library", "autoload": { - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" - }, "files": [ "src/DeepCopy/deep_copy.php" - ] + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -702,7 +704,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.10.2" + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" }, "funding": [ { @@ -710,7 +712,7 @@ "type": "tidelift" } ], - "time": "2020-11-13T09:40:50+00:00" + "time": "2022-03-03T13:19:32+00:00" }, { "name": "netresearch/jsonmapper", @@ -878,16 +880,17 @@ "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", - "reference": "97803eca37d319dfa7826cc2437fc020857acb53" + "reference": "36d8a21e851a9512db2b086dc5ac2c61308f0138" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", - "reference": "97803eca37d319dfa7826cc2437fc020857acb53", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/36d8a21e851a9512db2b086dc5ac2c61308f0138", + "reference": "36d8a21e851a9512db2b086dc5ac2c61308f0138", "shasum": "" }, "require": { "ext-dom": "*", + "ext-libxml": "*", "ext-phar": "*", "ext-xmlwriter": "*", "phar-io/version": "^3.0.1", @@ -929,22 +932,28 @@ "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", "support": { "issues": "https://github.com/phar-io/manifest/issues", - "source": "https://github.com/phar-io/manifest/tree/2.0.3" + "source": "https://github.com/phar-io/manifest/tree/master" }, - "time": "2021-07-20T11:28:43+00:00" + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2022-02-21T19:55:33+00:00" }, { "name": "phar-io/version", - "version": "3.1.0", + "version": "3.2.1", "source": { "type": "git", "url": "https://github.com/phar-io/version.git", - "reference": "bae7c545bef187884426f042434e561ab1ddb182" + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/bae7c545bef187884426f042434e561ab1ddb182", - "reference": "bae7c545bef187884426f042434e561ab1ddb182", + "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", "shasum": "" }, "require": { @@ -980,9 +989,9 @@ "description": "Library for handling version information and constraints", "support": { "issues": "https://github.com/phar-io/version/issues", - "source": "https://github.com/phar-io/version/tree/3.1.0" + "source": "https://github.com/phar-io/version/tree/3.2.1" }, - "time": "2021-02-23T14:00:09+00:00" + "time": "2022-02-21T01:04:05+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -1043,12 +1052,12 @@ "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" + "reference": "21481a5c97e8332f7279e31219c32faa2da21c79" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/21481a5c97e8332f7279e31219c32faa2da21c79", + "reference": "21481a5c97e8332f7279e31219c32faa2da21c79", "shasum": "" }, "require": { @@ -1059,7 +1068,7 @@ "webmozart/assert": "^1.9.1" }, "require-dev": { - "mockery/mockery": "~1.3.2", + "mockery/mockery": "~1.3.5", "psalm/phar": "^4.8" }, "default-branch": true, @@ -1091,9 +1100,9 @@ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" }, - "time": "2021-10-19T17:43:47+00:00" + "time": "2021-12-27T22:36:43+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -1101,12 +1110,12 @@ "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "f8ec4ab631de5a97769e66b13418c3b8b24e81f4" + "reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/f8ec4ab631de5a97769e66b13418c3b8b24e81f4", - "reference": "f8ec4ab631de5a97769e66b13418c3b8b24e81f4", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/93ebd0014cab80c4ea9f5e297ea48672f1b87706", + "reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706", "shasum": "" }, "require": { @@ -1142,9 +1151,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.x" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.0" }, - "time": "2021-11-24T08:29:39+00:00" + "time": "2022-01-04T19:58:01+00:00" }, { "name": "phpspec/prophecy", @@ -1220,12 +1229,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "299e0a60b0f5bd3296fd52290a585ac2b2517b65" + "reference": "9a61ec72f0d2b0b1d3f7431f90ab936b9c0e2062" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/299e0a60b0f5bd3296fd52290a585ac2b2517b65", - "reference": "299e0a60b0f5bd3296fd52290a585ac2b2517b65", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/9a61ec72f0d2b0b1d3f7431f90ab936b9c0e2062", + "reference": "9a61ec72f0d2b0b1d3f7431f90ab936b9c0e2062", "shasum": "" }, "require": { @@ -1289,7 +1298,7 @@ "type": "github" } ], - "time": "2021-12-05T09:19:13+00:00" + "time": "2022-03-08T06:18:06+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1297,12 +1306,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" + "reference": "38b24367e1b340aa78b96d7cab042942d917bb84" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", - "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/38b24367e1b340aa78b96d7cab042942d917bb84", + "reference": "38b24367e1b340aa78b96d7cab042942d917bb84", "shasum": "" }, "require": { @@ -1349,7 +1358,7 @@ "type": "github" } ], - "time": "2021-12-02T12:48:52+00:00" + "time": "2022-02-11T16:23:04+00:00" }, { "name": "phpunit/php-invoker", @@ -1538,12 +1547,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "02eb251b5a2c3dae82e16774eca8fabf7039fd7b" + "reference": "7699c48c8b2b75f885f9999786d3b92fe0802275" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/02eb251b5a2c3dae82e16774eca8fabf7039fd7b", - "reference": "02eb251b5a2c3dae82e16774eca8fabf7039fd7b", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/7699c48c8b2b75f885f9999786d3b92fe0802275", + "reference": "7699c48c8b2b75f885f9999786d3b92fe0802275", "shasum": "" }, "require": { @@ -1559,7 +1568,7 @@ "phar-io/version": "^3.0.2", "php": ">=7.3", "phpspec/prophecy": "^1.12.1", - "phpunit/php-code-coverage": "^9.2.7", + "phpunit/php-code-coverage": "^9.2.13", "phpunit/php-file-iterator": "^3.0.5", "phpunit/php-invoker": "^3.1.1", "phpunit/php-text-template": "^2.0.3", @@ -1573,7 +1582,7 @@ "sebastian/global-state": "^5.0.1", "sebastian/object-enumerator": "^4.0.3", "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^2.3.4", + "sebastian/type": "^3.0", "sebastian/version": "^3.0.2" }, "require-dev": { @@ -1594,11 +1603,11 @@ } }, "autoload": { - "classmap": [ - "src/" - ], "files": [ "src/Framework/Assert/Functions.php" + ], + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -1633,7 +1642,7 @@ "type": "github" } ], - "time": "2021-11-29T15:44:44+00:00" + "time": "2022-03-15T09:19:53+00:00" }, { "name": "psr/container", @@ -2172,12 +2181,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9" + "reference": "428c31e2ea8b292aa814bc460cf28d58eba4d2ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/65e8b7db476c5dd267e65eea9cab77584d3cfff9", - "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/428c31e2ea8b292aa814bc460cf28d58eba4d2ba", + "reference": "428c31e2ea8b292aa814bc460cf28d58eba4d2ba", "shasum": "" }, "require": { @@ -2241,20 +2250,20 @@ "type": "github" } ], - "time": "2021-11-11T14:18:36+00:00" + "time": "2022-03-06T06:59:32+00:00" }, { "name": "sebastian/global-state", - "version": "5.0.3", + "version": "5.0.x-dev", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49" + "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23bd5951f7ff26f12d4e3242864df3e08dec4e49", - "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2", + "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2", "shasum": "" }, "require": { @@ -2297,7 +2306,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.3" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5" }, "funding": [ { @@ -2305,7 +2314,7 @@ "type": "github" } ], - "time": "2021-06-11T13:31:12+00:00" + "time": "2022-02-14T08:28:10+00:00" }, { "name": "sebastian/lines-of-code", @@ -2584,7 +2593,6 @@ "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", "support": { - "issues": "https://github.com/sebastianbergmann/resource-operations/issues", "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" }, "funding": [ @@ -2597,28 +2605,28 @@ }, { "name": "sebastian/type", - "version": "2.3.x-dev", + "version": "3.0.x-dev", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "f24cbc541026c3bb7d27c647f0f9ea337135b22a" + "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/f24cbc541026c3bb7d27c647f0f9ea337135b22a", - "reference": "f24cbc541026c3bb7d27c647f0f9ea337135b22a", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b233b84bc4465aff7b57cf1c4bc75c86d00d6dad", + "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad", "shasum": "" }, "require": { "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^9.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -2641,7 +2649,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/2.3" + "source": "https://github.com/sebastianbergmann/type/tree/3.0.0" }, "funding": [ { @@ -2649,7 +2657,7 @@ "type": "github" } ], - "time": "2021-06-18T06:28:45+00:00" + "time": "2022-03-15T09:54:48+00:00" }, { "name": "sebastian/version", @@ -2710,12 +2718,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "9130e1a0fc93cb0faadca4ee917171bd2ca9e5f4" + "reference": "d8111acc99876953f52fe16d4c50eb60940d49ad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/9130e1a0fc93cb0faadca4ee917171bd2ca9e5f4", - "reference": "9130e1a0fc93cb0faadca4ee917171bd2ca9e5f4", + "url": "https://api.github.com/repos/symfony/console/zipball/d8111acc99876953f52fe16d4c50eb60940d49ad", + "reference": "d8111acc99876953f52fe16d4c50eb60940d49ad", "shasum": "" }, "require": { @@ -2786,7 +2794,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.1" + "source": "https://github.com/symfony/console/tree/v5.4.5" }, "funding": [ { @@ -2802,7 +2810,7 @@ "type": "tidelift" } ], - "time": "2021-12-09T11:22:43+00:00" + "time": "2022-02-24T12:45:35+00:00" }, { "name": "symfony/deprecation-contracts", @@ -2810,12 +2818,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "c726b64c1ccfe2896cb7df2e1331c357ad1c8ced" + "reference": "893fd20d9ae41a0bae2b9cbdd581ac0cf3917de3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/c726b64c1ccfe2896cb7df2e1331c357ad1c8ced", - "reference": "c726b64c1ccfe2896cb7df2e1331c357ad1c8ced", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/893fd20d9ae41a0bae2b9cbdd581ac0cf3917de3", + "reference": "893fd20d9ae41a0bae2b9cbdd581ac0cf3917de3", "shasum": "" }, "require": { @@ -2825,7 +2833,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "3.1-dev" }, "thanks": { "name": "symfony/contracts", @@ -2854,7 +2862,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.0.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/main" }, "funding": [ { @@ -2870,11 +2878,11 @@ "type": "tidelift" } ], - "time": "2021-11-01T23:48:49+00:00" + "time": "2021-11-29T18:10:03+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "dev-main", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", @@ -2895,7 +2903,6 @@ "suggest": { "ext-ctype": "For best performance" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -2907,12 +2914,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, "files": [ "bootstrap.php" - ] + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -2937,7 +2944,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/main" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.25.0" }, "funding": [ { @@ -2957,7 +2964,7 @@ }, { "name": "symfony/polyfill-intl-grapheme", - "version": "dev-main", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", @@ -2975,7 +2982,6 @@ "suggest": { "ext-intl": "For best performance" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -2987,12 +2993,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Intl\\Grapheme\\": "" - }, "files": [ "bootstrap.php" - ] + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -3019,7 +3025,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/main" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.25.0" }, "funding": [ { @@ -3039,7 +3045,7 @@ }, { "name": "symfony/polyfill-intl-normalizer", - "version": "dev-main", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", @@ -3057,7 +3063,6 @@ "suggest": { "ext-intl": "For best performance" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -3069,12 +3074,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Intl\\Normalizer\\": "" - }, "files": [ "bootstrap.php" ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, "classmap": [ "Resources/stubs" ] @@ -3104,7 +3109,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.25.0" }, "funding": [ { @@ -3124,7 +3129,7 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "dev-main", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", @@ -3145,7 +3150,6 @@ "suggest": { "ext-mbstring": "For best performance" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -3157,12 +3161,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, "files": [ "bootstrap.php" - ] + ], + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -3188,7 +3192,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/main" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.25.0" }, "funding": [ { @@ -3208,7 +3212,7 @@ }, { "name": "symfony/polyfill-php73", - "version": "dev-main", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", @@ -3223,7 +3227,6 @@ "require": { "php": ">=7.1" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -3235,12 +3238,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" - }, "files": [ "bootstrap.php" ], + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, "classmap": [ "Resources/stubs" ] @@ -3268,7 +3271,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/main" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.25.0" }, "funding": [ { @@ -3288,22 +3291,21 @@ }, { "name": "symfony/polyfill-php80", - "version": "dev-main", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9" + "reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/57b712b08eddb97c762a8caa32c84e037892d2e9", - "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/4407588e0d3f1f52efb65fbe92babe41f37fe50c", + "reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c", "shasum": "" }, "require": { "php": ">=7.1" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -3315,12 +3317,12 @@ } }, "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, "files": [ "bootstrap.php" ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, "classmap": [ "Resources/stubs" ] @@ -3352,7 +3354,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/main" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.25.0" }, "funding": [ { @@ -3368,7 +3370,7 @@ "type": "tidelift" } ], - "time": "2021-09-13T13:58:33+00:00" + "time": "2022-03-04T08:16:47+00:00" }, { "name": "symfony/service-contracts", @@ -3376,12 +3378,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "36715ebf9fb9db73db0cb24263c79077c6fe8603" + "reference": "bc0a2247c72d29241b5a06fb60dc1c9d9acf2a3a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/36715ebf9fb9db73db0cb24263c79077c6fe8603", - "reference": "36715ebf9fb9db73db0cb24263c79077c6fe8603", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/bc0a2247c72d29241b5a06fb60dc1c9d9acf2a3a", + "reference": "bc0a2247c72d29241b5a06fb60dc1c9d9acf2a3a", "shasum": "" }, "require": { @@ -3398,7 +3400,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "3.1-dev" }, "thanks": { "name": "symfony/contracts", @@ -3435,7 +3437,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.0.0" + "source": "https://github.com/symfony/service-contracts/tree/main" }, "funding": [ { @@ -3451,7 +3453,7 @@ "type": "tidelift" } ], - "time": "2021-11-04T17:53:12+00:00" + "time": "2021-11-29T18:10:03+00:00" }, { "name": "symfony/string", @@ -3459,16 +3461,16 @@ "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "aa14a00c4701b9cfbe21aec46972c493b3edddf5" + "reference": "6e0bf37c9c4826549e1c601123aa9d1b36b4f36e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/aa14a00c4701b9cfbe21aec46972c493b3edddf5", - "reference": "aa14a00c4701b9cfbe21aec46972c493b3edddf5", + "url": "https://api.github.com/repos/symfony/string/zipball/6e0bf37c9c4826549e1c601123aa9d1b36b4f36e", + "reference": "6e0bf37c9c4826549e1c601123aa9d1b36b4f36e", "shasum": "" }, "require": { - "php": ">=8.0.2", + "php": ">=8.1", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-intl-grapheme": "~1.0", "symfony/polyfill-intl-normalizer": "~1.0", @@ -3485,12 +3487,12 @@ }, "type": "library", "autoload": { - "psr-4": { - "Symfony\\Component\\String\\": "" - }, "files": [ "Resources/functions.php" ], + "psr-4": { + "Symfony\\Component\\String\\": "" + }, "exclude-from-classmap": [ "/Tests/" ] @@ -3536,7 +3538,7 @@ "type": "tidelift" } ], - "time": "2021-12-11T14:57:13+00:00" + "time": "2022-02-25T11:15:52+00:00" }, { "name": "theseer/tokenizer", @@ -3664,13 +3666,13 @@ } }, "autoload": { - "psr-4": { - "Psalm\\": "src/Psalm/" - }, "files": [ "src/functions.php", "src/spl_object_id.php" - ] + ], + "psr-4": { + "Psalm\\": "src/Psalm/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -3856,8 +3858,8 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.4" + "php": ">=8.0" }, "platform-dev": [], - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.2.0" } diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index 87842fdf..e2841607 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -161,7 +161,10 @@ public function transfer(string $path, string $destination, Device $device): boo for($counter; $counter < $totalChunks; $counter++) { $start = $counter * $this->transferChunkSize; $data = $this->read($path, $start, $this->transferChunkSize); - $device->upload($data, $destination, $counter+1, $totalChunks, $metadata); + $tmp = $this->getPath('tmp_' . microtime()); + $this->write($tmp, $data, $contentType); + $device->upload($tmp, $destination, $counter+1, $totalChunks, $metadata); + $this->delete($tmp); } return true; } diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 4943132e..1318f0a3 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -223,10 +223,14 @@ public function transfer(string $path, string $destination, Device $device): boo $totalChunks = \ceil($size / $this->transferChunkSize); $counter = 0; $metadata = ['content_type' => $contentType]; + $local = new Local('/tmp'); for($counter; $counter < $totalChunks; $counter++) { $start = $counter * $this->transferChunkSize; $data = $this->read($path, $start, $this->transferChunkSize); - $device->upload($data, $destination, $counter+1, $totalChunks, $metadata); + $tmp = $this->getPath('tmp_' . microtime()); + $local->write($tmp, $data, $contentType); + $device->upload($tmp, $destination, $counter+1, $totalChunks, $metadata); + $local->delete($tmp); } return true; } diff --git a/tests/Storage/Device/LocalTest.php b/tests/Storage/Device/LocalTest.php index d21665fb..825fd185 100644 --- a/tests/Storage/Device/LocalTest.php +++ b/tests/Storage/Device/LocalTest.php @@ -4,6 +4,7 @@ use Utopia\Storage\Device\Local; use PHPUnit\Framework\TestCase; +use Utopia\Storage\Device\S3; class LocalTest extends TestCase { @@ -209,7 +210,6 @@ public function testPartRead($path) { $chunk = file_get_contents($source, false,null, 0, 500); $readChunk = $this->object->read($path, 0, 500); $this->assertEquals($chunk, $readChunk); - $this->object->delete($path); } public function testPartitionFreeSpace() @@ -221,4 +221,26 @@ public function testPartitionTotalSpace() { $this->assertGreaterThan(0, $this->object->getPartitionTotalSpace()); } + + /** + * @depends testPartUpload + */ + public function testTransfer($path) { + // smaller file + $this->object->setTransferChunkSize(10000000); //10 mb + + $key = $_SERVER['S3_ACCESS_KEY'] ?? ''; + $secret = $_SERVER['S3_SECRET'] ?? ''; + $bucket = 'appwrite-storage'; + + $device = new S3('/root', $key, $secret, $bucket, S3::AP_SOUTH_1, S3::ACL_PRIVATE); + $destination = $device->getPath('largefile.mp4'); + + $this->assertTrue($this->object->transfer($path, $destination, $device )); + $this->assertTrue($device->exists($destination)); + $this->assertEquals($device->getFileMimeType($destination), 'video/mp4'); + + $device->delete($destination); + $this->object->delete($path); + } } From a987b602dc5bedc7ba081e3be94ef2d354220af4 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 15 Mar 2022 10:53:12 +0000 Subject: [PATCH 005/117] more test --- tests/Storage/Device/LocalTest.php | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/tests/Storage/Device/LocalTest.php b/tests/Storage/Device/LocalTest.php index 825fd185..6c4ee878 100644 --- a/tests/Storage/Device/LocalTest.php +++ b/tests/Storage/Device/LocalTest.php @@ -225,8 +225,9 @@ public function testPartitionTotalSpace() /** * @depends testPartUpload */ - public function testTransfer($path) { - // smaller file + public function testTransferLarge($path) { + + // chunked file $this->object->setTransferChunkSize(10000000); //10 mb $key = $_SERVER['S3_ACCESS_KEY'] ?? ''; @@ -242,5 +243,28 @@ public function testTransfer($path) { $device->delete($destination); $this->object->delete($path); + + } + + public function testTransferSmall() { + + $this->object->setTransferChunkSize(10000000); //10 mb + + $key = $_SERVER['S3_ACCESS_KEY'] ?? ''; + $secret = $_SERVER['S3_SECRET'] ?? ''; + $bucket = 'appwrite-storage'; + + $device = new S3('/root', $key, $secret, $bucket, S3::AP_SOUTH_1, S3::ACL_PRIVATE); + + $path = $this->object->getPath('text-for-read.txt'); + $this->object->write($path, 'Hello World'); + + $destination = $device->getPath('hello.txt'); + $this->assertTrue($this->object->transfer($path, $destination, $device)); + $this->assertTrue($device->exists($destination)); + $this->assertEquals($device->read($destination), 'Hello World'); + + $this->object->delete($path); + $device->delete($destination); } } From 8363ec1260dd0e34fbeadc4b2d4edc77c59f1252 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 15 Mar 2022 11:40:26 +0000 Subject: [PATCH 006/117] tests --- tests/Storage/Device/S3Test.php | 2 +- tests/Storage/S3Base.php | 38 +++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/tests/Storage/Device/S3Test.php b/tests/Storage/Device/S3Test.php index e9e81904..5489a2ac 100644 --- a/tests/Storage/Device/S3Test.php +++ b/tests/Storage/Device/S3Test.php @@ -13,7 +13,7 @@ protected function init(): void $this->root = '/root'; $key = $_SERVER['S3_ACCESS_KEY'] ?? ''; $secret = $_SERVER['S3_SECRET'] ?? ''; - $bucket = 'utopia-storage-tests'; + $bucket = 'appwrite-storage'; $this->object = new S3($this->root, $key, $secret, $bucket, S3::AP_SOUTH_1, S3::ACL_PRIVATE); } diff --git a/tests/Storage/S3Base.php b/tests/Storage/S3Base.php index feeb8193..7189d1b2 100644 --- a/tests/Storage/S3Base.php +++ b/tests/Storage/S3Base.php @@ -3,6 +3,7 @@ namespace Utopia\Tests; use PHPUnit\Framework\TestCase; +use Utopia\Storage\Device\Local; use Utopia\Storage\Device\S3; abstract class S3Base extends TestCase @@ -244,6 +245,43 @@ public function testPartRead($path) { $chunk = file_get_contents($source, false,null, 0, 500); $readChunk = $this->object->read($path, 0, 500); $this->assertEquals($chunk, $readChunk); + } + + /** + * @depends testPartUpload + */ + public function testTransferLarge($path) { + + // chunked file + $this->object->setTransferChunkSize(10000000); //10 mb + + $device = new Local('/root'); + $destination = $device->getPath('largefile.mp4'); + + $this->assertTrue($this->object->transfer($path, $destination, $device )); + $this->assertTrue($device->exists($destination)); + $this->assertEquals($device->getFileMimeType($destination), 'video/mp4'); + + $device->delete($destination); + $this->object->delete($path); + + } + + public function testTransferSmall() { + + $this->object->setTransferChunkSize(10000000); //10 mb + + $device = new Local('/root'); + + $path = $this->object->getPath('text-for-read.txt'); + $this->object->write($path, 'Hello World'); + + $destination = $device->getPath('hello.txt'); + $this->assertTrue($this->object->transfer($path, $destination, $device)); + $this->assertTrue($device->exists($destination)); + $this->assertEquals($device->read($destination), 'Hello World'); + $this->object->delete($path); + $device->delete($destination); } } From 3773001edaa7aa9438cc2fc50e505f40ae26d053 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 16 Mar 2022 10:36:12 +0000 Subject: [PATCH 007/117] refactored to implement transfer --- src/Storage/Device.php | 19 ++++++ src/Storage/Device/Local.php | 114 +++++++++++++++++++++++++++-------- src/Storage/Device/S3.php | 39 ++++++++---- 3 files changed, 135 insertions(+), 37 deletions(-) diff --git a/src/Storage/Device.php b/src/Storage/Device.php index 3ab90d08..3a15fbea 100644 --- a/src/Storage/Device.php +++ b/src/Storage/Device.php @@ -88,6 +88,25 @@ abstract public function getPath(string $filename, string $prefix = null): strin */ abstract public function upload(string $source, string $path, int $chunk = 1, int $chunks = 1, array &$metadata = []): int; + /** + * Upload Data. + * + * Upload file contents to desired destination in the selected disk. + * return number of chunks uploaded or 0 if it fails. + * + * @param string $source + * @param string $path + * @param string $contentType + * @param int chunk + * @param int chunks + * @param array $metadata + * + * @throws \Exception + * + * @return int + */ + abstract public function uploadData(string $data, string $path, string $contentType, int $chunk = 1, int $chunks = 1, array &$metadata = []): int; + /** * Abort Chunked Upload * diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index e2841607..172c61e3 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -83,11 +83,7 @@ public function getPath(string $filename, string $prefix = null): string */ public function upload(string $source, string $path, int $chunk = 1, int $chunks = 1, array &$metadata = []): int { - if (!\file_exists(\dirname($path))) { // Checks if directory path to file exists - if (!@\mkdir(\dirname($path), 0755, true)) { - throw new Exception('Can\'t create directory: ' . \dirname($path)); - } - } + $this->createDirectoryToPath($path); //move_uploaded_file() verifies the file is not tampered with if($chunks === 1) { @@ -98,11 +94,7 @@ public function upload(string $source, string $path, int $chunk = 1, int $chunks } $tmp = \dirname($path) . DIRECTORY_SEPARATOR . 'tmp_' . \basename($path) . DIRECTORY_SEPARATOR . \basename($path) . '_chunks.log'; - if (!\file_exists(\dirname($tmp))) { // Checks if directory path to file exists - if (!@\mkdir(\dirname($tmp), 0755, true)) { - throw new Exception('Can\'t create directory: ' . \dirname($tmp)); - } - } + $this->createDirectoryToPath($tmp); if(!file_put_contents($tmp, "$chunk\n", FILE_APPEND)) { throw new Exception('Can\'t write chunk log ' . $tmp); } @@ -119,24 +111,97 @@ public function upload(string $source, string $path, int $chunk = 1, int $chunks } if ($chunks === $chunksReceived) { - for($i = 1; $i <= $chunks; $i++) { - $part = dirname($tmp) . DIRECTORY_SEPARATOR . pathinfo($path, PATHINFO_FILENAME) . '.part.'. $i; - $data = file_get_contents($part); - if(!$data) { - throw new Exception('Failed to read chunk ' . $part); - } - - if(!file_put_contents($path, $data, FILE_APPEND)) { - throw new Exception('Failed to append chunk ' . $part); - } - \unlink($part); + $this->joinChunks($path, $chunks); + return $chunksReceived; + } + return $chunksReceived; + } + + /** + * Upload Data. + * + * Upload file contents to desired destination in the selected disk. + * return number of chunks uploaded or 0 if it fails. + * + * @param string $source + * @param string $path + * @param string $contentType + * @param int chunk + * @param int chunks + * @param array $metadata + * + * @throws \Exception + * + * @return int + */ + public function uploadData(string $data, string $path, string $contentType, int $chunk = 1, int $chunks = 1, array &$metadata = []): int + { + $this->createDirectoryToPath($path); + + if($chunks === 1) { + if(!\file_put_contents($path, $data)) { + throw new Exception('Can\'t write file ' . $path); } - \unlink($tmp); + return $chunks; + } + $tmp = \dirname($path) . DIRECTORY_SEPARATOR . 'tmp_' . \basename($path) . DIRECTORY_SEPARATOR . \basename($path) . '_chunks.log'; + + $this->createDirectoryToPath($tmp); + if(!file_put_contents($tmp, "$chunk\n", FILE_APPEND)) { + throw new Exception('Can\'t write chunk log ' . $tmp); + } + + $chunkLogs = file($tmp); + if(!$chunkLogs) { + throw new Exception('Unable to read chunk log ' . $tmp); + } + + $chunksReceived = count(file($tmp)); + + if(!\file_put_contents(dirname($tmp) . DIRECTORY_SEPARATOR . pathinfo($path, PATHINFO_FILENAME) . '.part.' . $chunk, $data)) { + throw new Exception('Failed to write chunk ' . $chunk); + } + + if ($chunks === $chunksReceived) { + $this->joinChunks($path, $chunks); return $chunksReceived; } return $chunksReceived; } + private function joinChunks(string $path, int $chunks) { + $tmp = \dirname($path) . DIRECTORY_SEPARATOR . 'tmp_' . \basename($path) . DIRECTORY_SEPARATOR . \basename($path) . '_chunks.log'; + for($i = 1; $i <= $chunks; $i++) { + $part = dirname($tmp) . DIRECTORY_SEPARATOR . pathinfo($path, PATHINFO_FILENAME) . '.part.'. $i; + $data = file_get_contents($part); + if(!$data) { + throw new Exception('Failed to read chunk ' . $part); + } + + if(!file_put_contents($path, $data, FILE_APPEND)) { + throw new Exception('Failed to append chunk ' . $part); + } + \unlink($part); + } + \unlink($tmp); + } + + /** + * Create Directory to Path + * + * Create's missing directory of the path, returns true on success and false on failure + * + * @param string path + * @throws Exception + */ + private function createDirectoryToPath(string $path): void { + if (!\file_exists(\dirname($path))) { // Checks if directory path to file exists + if (!@\mkdir(\dirname($path), 0755, true)) { + throw new Exception('Can\'t create directory: ' . \dirname($path)); + } + } + } + /** * Transfer * @@ -161,10 +226,7 @@ public function transfer(string $path, string $destination, Device $device): boo for($counter; $counter < $totalChunks; $counter++) { $start = $counter * $this->transferChunkSize; $data = $this->read($path, $start, $this->transferChunkSize); - $tmp = $this->getPath('tmp_' . microtime()); - $this->write($tmp, $data, $contentType); - $device->upload($tmp, $destination, $counter+1, $totalChunks, $metadata); - $this->delete($tmp); + $device->uploadData($data, $destination, $contentType, $counter+1, $totalChunks, $metadata); } return true; } diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 7df03589..a1044833 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -180,17 +180,39 @@ public function getPath(string $filename, string $prefix = null): string * @return int */ public function upload(string $source, string $path, int $chunk = 1, int $chunks = 1, array &$metadata = []): int + { + return $this->uploadData(\file_get_contents($source), $path, \mime_content_type($source), $chunk, $chunks, $metadata); + } + + /** + * Upload Data. + * + * Upload file contents to desired destination in the selected disk. + * return number of chunks uploaded or 0 if it fails. + * + * @param string $source + * @param string $path + * @param string $contentType + * @param int chunk + * @param int chunks + * @param array $metadata + * + * @throws \Exception + * + * @return int + */ + public function uploadData(string $data, string $path, string $contentType, int $chunk = 1, int $chunks = 1, array &$metadata = []): int { if($chunk == 1 && $chunks == 1) { - return $this->write($path, \file_get_contents($source), \mime_content_type($source)); + return $this->write($path, $data, $contentType); } $uploadId = $metadata['uploadId'] ?? null; if(empty($uploadId)) { - $uploadId = $this->createMultipartUpload($path, $metadata['content_type']); + $uploadId = $this->createMultipartUpload($path, $contentType); $metadata['uploadId'] = $uploadId; } - $etag = $this->uploadPart($source, $path, $chunk, $uploadId); + $etag = $this->uploadPart($data, $path, $contentType, $chunk, $uploadId); $metadata['parts'] ??= []; $metadata['parts'][] = ['partNumber' => $chunk, 'etag' => $etag]; $metadata['chunks'] ??= 0; @@ -223,14 +245,10 @@ public function transfer(string $path, string $destination, Device $device): boo $totalChunks = \ceil($size / $this->transferChunkSize); $counter = 0; $metadata = ['content_type' => $contentType]; - $local = new Local('/tmp'); for($counter; $counter < $totalChunks; $counter++) { $start = $counter * $this->transferChunkSize; $data = $this->read($path, $start, $this->transferChunkSize); - $tmp = $this->getPath('tmp_' . microtime()); - $local->write($tmp, $data, $contentType); - $device->upload($tmp, $destination, $counter+1, $totalChunks, $metadata); - $local->delete($tmp); + $device->uploadData($data, $destination, $contentType, $counter+1, $totalChunks, $metadata); } return true; } @@ -271,12 +289,11 @@ protected function createMultipartUpload(string $path, string $contentType): str * * @return string */ - protected function uploadPart(string $source, string $path, int $chunk, string $uploadId) : string + protected function uploadPart(string $data, string $path, string $contentType, int $chunk, string $uploadId) : string { $uri = $path !== '' ? '/' . \str_replace(['%2F', '%3F'], ['/', '?'], \rawurlencode($path)) : '/'; - $data = \file_get_contents($source); - $this->headers['content-type'] = \mime_content_type($source); + $this->headers['content-type'] = $contentType; $this->headers['content-md5'] = \base64_encode(md5($data, true)); $this->amzHeaders['x-amz-content-sha256'] = \hash('sha256', $data); unset($this->amzHeaders['x-amz-acl']); // ACL header is not allowed in parts, only createMultipartUpload accepts this header. From 39734038c0f7e6da59ed7df61f6e96af2dcb85ec Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 16 Mar 2022 13:45:52 +0000 Subject: [PATCH 008/117] fix transfer test --- tests/Storage/S3Base.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Storage/S3Base.php b/tests/Storage/S3Base.php index 7189d1b2..91cf3729 100644 --- a/tests/Storage/S3Base.php +++ b/tests/Storage/S3Base.php @@ -255,7 +255,7 @@ public function testTransferLarge($path) { // chunked file $this->object->setTransferChunkSize(10000000); //10 mb - $device = new Local('/root'); + $device = new Local(__DIR__ . '/../resources/disk-a'); $destination = $device->getPath('largefile.mp4'); $this->assertTrue($this->object->transfer($path, $destination, $device )); @@ -271,7 +271,7 @@ public function testTransferSmall() { $this->object->setTransferChunkSize(10000000); //10 mb - $device = new Local('/root'); + $device = new Local(__DIR__ . '/../resources/disk-a'); $path = $this->object->getPath('text-for-read.txt'); $this->object->write($path, 'Hello World'); From e6219d43b6bf0b171567002a49e2eb9f8370ce52 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 16 Mar 2022 14:08:56 +0000 Subject: [PATCH 009/117] fix bucket name --- tests/Storage/Device/LocalTest.php | 2 +- tests/Storage/Device/S3Test.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Storage/Device/LocalTest.php b/tests/Storage/Device/LocalTest.php index 6c4ee878..27c349a6 100644 --- a/tests/Storage/Device/LocalTest.php +++ b/tests/Storage/Device/LocalTest.php @@ -252,7 +252,7 @@ public function testTransferSmall() { $key = $_SERVER['S3_ACCESS_KEY'] ?? ''; $secret = $_SERVER['S3_SECRET'] ?? ''; - $bucket = 'appwrite-storage'; + $bucket = 'utopia-storage-tests'; $device = new S3('/root', $key, $secret, $bucket, S3::AP_SOUTH_1, S3::ACL_PRIVATE); diff --git a/tests/Storage/Device/S3Test.php b/tests/Storage/Device/S3Test.php index 5489a2ac..e9e81904 100644 --- a/tests/Storage/Device/S3Test.php +++ b/tests/Storage/Device/S3Test.php @@ -13,7 +13,7 @@ protected function init(): void $this->root = '/root'; $key = $_SERVER['S3_ACCESS_KEY'] ?? ''; $secret = $_SERVER['S3_SECRET'] ?? ''; - $bucket = 'appwrite-storage'; + $bucket = 'utopia-storage-tests'; $this->object = new S3($this->root, $key, $secret, $bucket, S3::AP_SOUTH_1, S3::ACL_PRIVATE); } From b8d9790484d15a9894f335ba334b44649f700246 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Fri, 18 Mar 2022 06:19:28 +0000 Subject: [PATCH 010/117] fix tests --- tests/Storage/Device/LocalTest.php | 2 +- tests/Storage/S3Base.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Storage/Device/LocalTest.php b/tests/Storage/Device/LocalTest.php index 27c349a6..80030708 100644 --- a/tests/Storage/Device/LocalTest.php +++ b/tests/Storage/Device/LocalTest.php @@ -232,7 +232,7 @@ public function testTransferLarge($path) { $key = $_SERVER['S3_ACCESS_KEY'] ?? ''; $secret = $_SERVER['S3_SECRET'] ?? ''; - $bucket = 'appwrite-storage'; + $bucket = 'utopia-storage-tests'; $device = new S3('/root', $key, $secret, $bucket, S3::AP_SOUTH_1, S3::ACL_PRIVATE); $destination = $device->getPath('largefile.mp4'); diff --git a/tests/Storage/S3Base.php b/tests/Storage/S3Base.php index 91cf3729..89ff7029 100644 --- a/tests/Storage/S3Base.php +++ b/tests/Storage/S3Base.php @@ -274,7 +274,7 @@ public function testTransferSmall() { $device = new Local(__DIR__ . '/../resources/disk-a'); $path = $this->object->getPath('text-for-read.txt'); - $this->object->write($path, 'Hello World'); + $this->object->write($path, 'Hello World', 'text/plain'); $destination = $device->getPath('hello.txt'); $this->assertTrue($this->object->transfer($path, $destination, $device)); From b80a2e415d5dc3c3bc82413690ef7de13bcea625 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Fri, 18 Mar 2022 08:18:37 +0000 Subject: [PATCH 011/117] fix move --- src/Storage/Device/S3.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index a1044833..d6c931b4 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -416,7 +416,10 @@ public function write(string $path, string $data, string $contentType = ''): boo */ public function move(string $source, string $target): bool { - return $this->transfer($source, $target, $this); + if($this->transfer($source, $target, $this)) { + return $this->delete($source); + } + return false; } /** From eb1c769ae7eb6264909e7f191e9f543e824acf0b Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 23 May 2022 06:54:15 +0000 Subject: [PATCH 012/117] move implementation in device --- src/Storage/Device.php | 10 ++++++++-- src/Storage/Device/S3.php | 20 -------------------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/src/Storage/Device.php b/src/Storage/Device.php index 3a15fbea..e3c7d573 100644 --- a/src/Storage/Device.php +++ b/src/Storage/Device.php @@ -94,7 +94,7 @@ abstract public function upload(string $source, string $path, int $chunk = 1, in * Upload file contents to desired destination in the selected disk. * return number of chunks uploaded or 0 if it fails. * - * @param string $source + * @param string $data * @param string $path * @param string $contentType * @param int chunk @@ -159,7 +159,13 @@ abstract public function write(string $path, string $data, string $contentType): * * @return bool */ - abstract public function move(string $source, string $target): bool; + public function move(string $source, string $target): bool + { + if($this->transfer($source, $target, $this)) { + return $this->delete($source); + } + return false; + } /** * Delete file in given path return true on success and false on failure. diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index d6c931b4..1caacc59 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -402,26 +402,6 @@ public function write(string $path, string $data, string $contentType = ''): boo return true; } - /** - * Move file from given source to given path, Return true on success and false on failure. - * - * @see http://php.net/manual/en/function.filesize.php - * - * @param string $source - * @param string $target - * - * @throw \Exception - * - * @return bool - */ - public function move(string $source, string $target): bool - { - if($this->transfer($source, $target, $this)) { - return $this->delete($source); - } - return false; - } - /** * Delete file in given path, Return true on success and false on failure. * From 53e185589bc79feb195c1567c303885af35b7152 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 23 May 2022 08:43:56 +0000 Subject: [PATCH 013/117] update test bucket and region --- tests/Storage/Device/S3Test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Storage/Device/S3Test.php b/tests/Storage/Device/S3Test.php index e9e81904..dd6e61e2 100644 --- a/tests/Storage/Device/S3Test.php +++ b/tests/Storage/Device/S3Test.php @@ -13,9 +13,9 @@ protected function init(): void $this->root = '/root'; $key = $_SERVER['S3_ACCESS_KEY'] ?? ''; $secret = $_SERVER['S3_SECRET'] ?? ''; - $bucket = 'utopia-storage-tests'; + $bucket = 'appwrite-test-bucket'; - $this->object = new S3($this->root, $key, $secret, $bucket, S3::AP_SOUTH_1, S3::ACL_PRIVATE); + $this->object = new S3($this->root, $key, $secret, $bucket, S3::EU_WEST_1, S3::ACL_PRIVATE); } /** From 63dd53c366899f196378f8b5ffb49778e112e072 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 24 May 2022 04:14:42 +0000 Subject: [PATCH 014/117] fix transfer test s3 credentials --- tests/Storage/Device/LocalTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Storage/Device/LocalTest.php b/tests/Storage/Device/LocalTest.php index 80030708..ea7ce845 100644 --- a/tests/Storage/Device/LocalTest.php +++ b/tests/Storage/Device/LocalTest.php @@ -252,9 +252,9 @@ public function testTransferSmall() { $key = $_SERVER['S3_ACCESS_KEY'] ?? ''; $secret = $_SERVER['S3_SECRET'] ?? ''; - $bucket = 'utopia-storage-tests'; + $bucket = 'appwrite-test-bucket'; - $device = new S3('/root', $key, $secret, $bucket, S3::AP_SOUTH_1, S3::ACL_PRIVATE); + $device = new S3('/root', $key, $secret, $bucket, S3::EU_WEST_1, S3::ACL_PRIVATE); $path = $this->object->getPath('text-for-read.txt'); $this->object->write($path, 'Hello World'); From aa2bb18c7680632efd646efc1b9987591e822ec3 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 24 May 2022 05:15:59 +0000 Subject: [PATCH 015/117] update test bucket --- tests/Storage/Device/LocalTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Storage/Device/LocalTest.php b/tests/Storage/Device/LocalTest.php index ea7ce845..bff48044 100644 --- a/tests/Storage/Device/LocalTest.php +++ b/tests/Storage/Device/LocalTest.php @@ -232,9 +232,9 @@ public function testTransferLarge($path) { $key = $_SERVER['S3_ACCESS_KEY'] ?? ''; $secret = $_SERVER['S3_SECRET'] ?? ''; - $bucket = 'utopia-storage-tests'; + $bucket = 'appwrite-test-bucket'; - $device = new S3('/root', $key, $secret, $bucket, S3::AP_SOUTH_1, S3::ACL_PRIVATE); + $device = new S3('/root', $key, $secret, $bucket, S3::EU_WEST_1, S3::ACL_PRIVATE); $destination = $device->getPath('largefile.mp4'); $this->assertTrue($this->object->transfer($path, $destination, $device )); From a7b838430b5e0d1e17816f427eb814c405c66828 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 2 Mar 2023 00:46:43 +0000 Subject: [PATCH 016/117] fix formatting --- src/Storage/Device.php | 34 ++++++------ src/Storage/Device/Local.php | 86 ++++++++++++++++-------------- src/Storage/Device/S3.php | 41 +++++++------- tests/Storage/Device/LocalTest.php | 19 ++++--- tests/Storage/S3Base.php | 17 +++--- 5 files changed, 102 insertions(+), 95 deletions(-) diff --git a/src/Storage/Device.php b/src/Storage/Device.php index 27b4b745..9bccd279 100644 --- a/src/Storage/Device.php +++ b/src/Storage/Device.php @@ -4,7 +4,6 @@ abstract class Device { - /** * Max chunk size while transfering file from one device to another */ @@ -12,20 +11,22 @@ abstract class Device /** * Set Transfer Chunk Size - * - * @param int $chunkSize + * + * @param int $chunkSize * @return void */ - public function setTransferChunkSize(int $chunkSize): void { + public function setTransferChunkSize(int $chunkSize): void + { $this->transferChunkSize = $chunkSize; } /** * Get Transfer Chunk Size - * + * * @return int */ - public function getTransferChunkSize(): int { + public function getTransferChunkSize(): int + { return $this->transferChunkSize; } @@ -99,16 +100,15 @@ abstract public function upload(string $source, string $path, int $chunk = 1, in * Upload file contents to desired destination in the selected disk. * return number of chunks uploaded or 0 if it fails. * - * @param string $data - * @param string $path - * @param string $contentType + * @param string $data + * @param string $path + * @param string $contentType * @param int chunk * @param int chunks - * @param array $metadata + * @param array $metadata + * @return int * * @throws \Exception - * - * @return int */ abstract public function uploadData(string $data, string $path, string $contentType, int $chunk = 1, int $chunks = 1, array &$metadata = []): int; @@ -134,10 +134,9 @@ abstract public function read(string $path, int $offset = 0, int $length = null) /** * Transfer * - * @param string $path - * @param string $destination - * @param Device $device - * + * @param string $path + * @param string $destination + * @param Device $device * @return string */ abstract public function transfer(string $path, string $destination, Device $device): bool; @@ -162,9 +161,10 @@ abstract public function write(string $path, string $data, string $contentType): */ public function move(string $source, string $target): bool { - if($this->transfer($source, $target, $this)) { + if ($this->transfer($source, $target, $this)) { return $this->delete($source); } + return false; } diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index ccca4eea..e10affd5 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -95,8 +95,8 @@ public function upload(string $source, string $path, int $chunk = 1, int $chunks $tmp = \dirname($path).DIRECTORY_SEPARATOR.'tmp_'.\basename($path).DIRECTORY_SEPARATOR.\basename($path).'_chunks.log'; $this->createDirectoryToPath($tmp); - if(!file_put_contents($tmp, "$chunk\n", FILE_APPEND)) { - throw new Exception('Can\'t write chunk log ' . $tmp); + if (! file_put_contents($tmp, "$chunk\n", FILE_APPEND)) { + throw new Exception('Can\'t write chunk log '.$tmp); } $chunkLogs = file($tmp); @@ -112,6 +112,7 @@ public function upload(string $source, string $path, int $chunk = 1, int $chunks if ($chunks === $chunksReceived) { $this->joinChunks($path, $chunks); + return $chunksReceived; } @@ -124,63 +125,66 @@ public function upload(string $source, string $path, int $chunk = 1, int $chunks * Upload file contents to desired destination in the selected disk. * return number of chunks uploaded or 0 if it fails. * - * @param string $source - * @param string $path - * @param string $contentType + * @param string $source + * @param string $path + * @param string $contentType * @param int chunk * @param int chunks - * @param array $metadata + * @param array $metadata + * @return int * * @throws \Exception - * - * @return int */ public function uploadData(string $data, string $path, string $contentType, int $chunk = 1, int $chunks = 1, array &$metadata = []): int { $this->createDirectoryToPath($path); - if($chunks === 1) { - if(!\file_put_contents($path, $data)) { - throw new Exception('Can\'t write file ' . $path); + if ($chunks === 1) { + if (! \file_put_contents($path, $data)) { + throw new Exception('Can\'t write file '.$path); } + return $chunks; } - $tmp = \dirname($path) . DIRECTORY_SEPARATOR . 'tmp_' . \basename($path) . DIRECTORY_SEPARATOR . \basename($path) . '_chunks.log'; + $tmp = \dirname($path).DIRECTORY_SEPARATOR.'tmp_'.\basename($path).DIRECTORY_SEPARATOR.\basename($path).'_chunks.log'; $this->createDirectoryToPath($tmp); - if(!file_put_contents($tmp, "$chunk\n", FILE_APPEND)) { - throw new Exception('Can\'t write chunk log ' . $tmp); + if (! file_put_contents($tmp, "$chunk\n", FILE_APPEND)) { + throw new Exception('Can\'t write chunk log '.$tmp); } $chunkLogs = file($tmp); - if(!$chunkLogs) { - throw new Exception('Unable to read chunk log ' . $tmp); + if (! $chunkLogs) { + throw new Exception('Unable to read chunk log '.$tmp); } $chunksReceived = count(file($tmp)); - if(!\file_put_contents(dirname($tmp) . DIRECTORY_SEPARATOR . pathinfo($path, PATHINFO_FILENAME) . '.part.' . $chunk, $data)) { - throw new Exception('Failed to write chunk ' . $chunk); + if (! \file_put_contents(dirname($tmp).DIRECTORY_SEPARATOR.pathinfo($path, PATHINFO_FILENAME).'.part.'.$chunk, $data)) { + throw new Exception('Failed to write chunk '.$chunk); } - + if ($chunks === $chunksReceived) { $this->joinChunks($path, $chunks); + return $chunksReceived; } + return $chunksReceived; } - private function joinChunks(string $path, int $chunks) { - $tmp = \dirname($path) . DIRECTORY_SEPARATOR . 'tmp_' . \basename($path) . DIRECTORY_SEPARATOR . \basename($path) . '_chunks.log'; - for($i = 1; $i <= $chunks; $i++) { - $part = dirname($tmp) . DIRECTORY_SEPARATOR . pathinfo($path, PATHINFO_FILENAME) . '.part.'. $i; + private function joinChunks(string $path, int $chunks) + { + $tmp = \dirname($path).DIRECTORY_SEPARATOR.'tmp_'.\basename($path).DIRECTORY_SEPARATOR.\basename($path).'_chunks.log'; + for ($i = 1; $i <= $chunks; $i++) { + $part = dirname($tmp).DIRECTORY_SEPARATOR.pathinfo($path, PATHINFO_FILENAME).'.part.'.$i; $data = file_get_contents($part); - if(!$data) { - throw new Exception('Failed to read chunk ' . $part); + if (! $data) { + throw new Exception('Failed to read chunk '.$part); } - if(!file_put_contents($path, $data, FILE_APPEND)) { - throw new Exception('Failed to append chunk ' . $part); + if (! file_put_contents($path, $data, FILE_APPEND)) { + throw new Exception('Failed to append chunk '.$part); } \unlink($part); } @@ -189,13 +193,15 @@ private function joinChunks(string $path, int $chunks) { /** * Create Directory to Path - * + * * Create's missing directory of the path, returns true on success and false on failure - * + * * @param string path + * * @throws Exception */ - private function createDirectoryToPath(string $path): void { + private function createDirectoryToPath(string $path): void + { if (! \file_exists(\dirname($path))) { // Checks if directory path to file exists if (! @\mkdir(\dirname($path), 0755, true)) { throw new Exception('Can\'t create directory: '.\dirname($path)); @@ -206,30 +212,32 @@ private function createDirectoryToPath(string $path): void { /** * Transfer * - * @param string $path - * @param string $destination - * @param Device $device - * + * @param string $path + * @param string $destination + * @param Device $device * @return string */ - public function transfer(string $path, string $destination, Device $device): bool { + public function transfer(string $path, string $destination, Device $device): bool + { $size = $this->getFileSize($path); $contentType = $this->getFileMimeType($path); - if($size <= $this->transferChunkSize) { + if ($size <= $this->transferChunkSize) { $source = $this->read($path); + return $device->write($destination, $source, $contentType); } $totalChunks = \ceil($size / $this->transferChunkSize); $counter = 0; $metadata = ['content_type' => $contentType]; - for($counter; $counter < $totalChunks; $counter++) { + for ($counter; $counter < $totalChunks; $counter++) { $start = $counter * $this->transferChunkSize; $data = $this->read($path, $start, $this->transferChunkSize); - $device->uploadData($data, $destination, $contentType, $counter+1, $totalChunks, $metadata); + $device->uploadData($data, $destination, $contentType, $counter + 1, $totalChunks, $metadata); } - return true; + + return true; } /** diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index f0030fb1..487a25a8 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -232,24 +232,23 @@ public function upload(string $source, string $path, int $chunk = 1, int $chunks * Upload file contents to desired destination in the selected disk. * return number of chunks uploaded or 0 if it fails. * - * @param string $source - * @param string $path - * @param string $contentType + * @param string $source + * @param string $path + * @param string $contentType * @param int chunk * @param int chunks - * @param array $metadata + * @param array $metadata + * @return int * * @throws \Exception - * - * @return int */ public function uploadData(string $data, string $path, string $contentType, int $chunk = 1, int $chunks = 1, array &$metadata = []): int { - if($chunk == 1 && $chunks == 1) { + if ($chunk == 1 && $chunks == 1) { return $this->write($path, $data, $contentType); } $uploadId = $metadata['uploadId'] ?? null; - if(empty($uploadId)) { + if (empty($uploadId)) { $uploadId = $this->createMultipartUpload($path, $contentType); $metadata['uploadId'] = $uploadId; } @@ -269,31 +268,33 @@ public function uploadData(string $data, string $path, string $contentType, int /** * Transfer * - * @param string $path - * @param string $destination - * @param Device $device - * + * @param string $path + * @param string $destination + * @param Device $device * @return string */ - public function transfer(string $path, string $destination, Device $device): bool { + public function transfer(string $path, string $destination, Device $device): bool + { $response = $this->getInfo($path); - $size = (int)($response['content-length'] ?? 0); + $size = (int) ($response['content-length'] ?? 0); $contentType = $response['content-type'] ?? ''; - if($size <= $this->transferChunkSize) { + if ($size <= $this->transferChunkSize) { $source = $this->read($path); + return $device->write($destination, $source, $contentType); } $totalChunks = \ceil($size / $this->transferChunkSize); $counter = 0; $metadata = ['content_type' => $contentType]; - for($counter; $counter < $totalChunks; $counter++) { + for ($counter; $counter < $totalChunks; $counter++) { $start = $counter * $this->transferChunkSize; $data = $this->read($path, $start, $this->transferChunkSize); - $device->uploadData($data, $destination, $contentType, $counter+1, $totalChunks, $metadata); + $device->uploadData($data, $destination, $contentType, $counter + 1, $totalChunks, $metadata); } - return true; + + return true; } /** @@ -331,10 +332,10 @@ protected function createMultipartUpload(string $path, string $contentType): str * * @throws \Exception */ - protected function uploadPart(string $data, string $path, string $contentType, int $chunk, string $uploadId) : string + protected function uploadPart(string $data, string $path, string $contentType, int $chunk, string $uploadId): string { $uri = $path !== '' ? '/'.\str_replace(['%2F', '%3F'], ['/', '?'], \rawurlencode($path)) : '/'; - + $this->headers['content-type'] = $contentType; $this->headers['content-md5'] = \base64_encode(md5($data, true)); $this->amzHeaders['x-amz-content-sha256'] = \hash('sha256', $data); diff --git a/tests/Storage/Device/LocalTest.php b/tests/Storage/Device/LocalTest.php index 98af9a80..846e366d 100644 --- a/tests/Storage/Device/LocalTest.php +++ b/tests/Storage/Device/LocalTest.php @@ -3,8 +3,8 @@ namespace Utopia\Tests\Storage\Device; use PHPUnit\Framework\TestCase; -use Utopia\Storage\Device\S3; use Utopia\Storage\Device\Local; +use Utopia\Storage\Device\S3; class LocalTest extends TestCase { @@ -250,11 +250,11 @@ public function testPartitionTotalSpace() /** * @depends testPartUpload */ - public function testTransferLarge($path) { - + public function testTransferLarge($path) + { // chunked file $this->object->setTransferChunkSize(10000000); //10 mb - + $key = $_SERVER['S3_ACCESS_KEY'] ?? ''; $secret = $_SERVER['S3_SECRET'] ?? ''; $bucket = 'appwrite-test-bucket'; @@ -262,25 +262,24 @@ public function testTransferLarge($path) { $device = new S3('/root', $key, $secret, $bucket, S3::EU_WEST_1, S3::ACL_PRIVATE); $destination = $device->getPath('largefile.mp4'); - $this->assertTrue($this->object->transfer($path, $destination, $device )); + $this->assertTrue($this->object->transfer($path, $destination, $device)); $this->assertTrue($device->exists($destination)); $this->assertEquals($device->getFileMimeType($destination), 'video/mp4'); $device->delete($destination); $this->object->delete($path); - } - public function testTransferSmall() { - + public function testTransferSmall() + { $this->object->setTransferChunkSize(10000000); //10 mb - + $key = $_SERVER['S3_ACCESS_KEY'] ?? ''; $secret = $_SERVER['S3_SECRET'] ?? ''; $bucket = 'appwrite-test-bucket'; $device = new S3('/root', $key, $secret, $bucket, S3::EU_WEST_1, S3::ACL_PRIVATE); - + $path = $this->object->getPath('text-for-read.txt'); $this->object->write($path, 'Hello World'); diff --git a/tests/Storage/S3Base.php b/tests/Storage/S3Base.php index 7a25d521..4da0c94c 100644 --- a/tests/Storage/S3Base.php +++ b/tests/Storage/S3Base.php @@ -259,29 +259,28 @@ public function testPartRead($path) /** * @depends testPartUpload */ - public function testTransferLarge($path) { - + public function testTransferLarge($path) + { // chunked file $this->object->setTransferChunkSize(10000000); //10 mb - $device = new Local(__DIR__ . '/../resources/disk-a'); + $device = new Local(__DIR__.'/../resources/disk-a'); $destination = $device->getPath('largefile.mp4'); - $this->assertTrue($this->object->transfer($path, $destination, $device )); + $this->assertTrue($this->object->transfer($path, $destination, $device)); $this->assertTrue($device->exists($destination)); $this->assertEquals($device->getFileMimeType($destination), 'video/mp4'); $device->delete($destination); $this->object->delete($path); - } - public function testTransferSmall() { - + public function testTransferSmall() + { $this->object->setTransferChunkSize(10000000); //10 mb - $device = new Local(__DIR__ . '/../resources/disk-a'); - + $device = new Local(__DIR__.'/../resources/disk-a'); + $path = $this->object->getPath('text-for-read.txt'); $this->object->write($path, 'Hello World', 'text/plain'); From 2ad603be850e6493d3981af9d92126dc0b8f4c60 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 2 Mar 2023 01:51:59 +0000 Subject: [PATCH 017/117] added check to make sure file exists --- src/Storage/Device/Local.php | 3 +++ src/Storage/Device/S3.php | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index e10affd5..57155c7c 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -219,6 +219,9 @@ private function createDirectoryToPath(string $path): void */ public function transfer(string $path, string $destination, Device $device): bool { + if (! $this->exists($path)) { + throw new Exception('File Not Found'); + } $size = $this->getFileSize($path); $contentType = $this->getFileMimeType($path); diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 487a25a8..3f78cd31 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -275,7 +275,12 @@ public function uploadData(string $data, string $path, string $contentType, int */ public function transfer(string $path, string $destination, Device $device): bool { - $response = $this->getInfo($path); + $response = []; + try { + $response = $this->getInfo($path); + } catch (\Throwable $e) { + throw new Exception('File not found'); + } $size = (int) ($response['content-length'] ?? 0); $contentType = $response['content-type'] ?? ''; From 851d515366436b0e7f40e8da52b39b28f0fa70bb Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Fri, 3 Mar 2023 00:25:41 +0000 Subject: [PATCH 018/117] update review suggestions --- src/Storage/Device.php | 2 +- src/Storage/Device/Local.php | 26 ++++---------------------- src/Storage/Device/S3.php | 3 +-- 3 files changed, 6 insertions(+), 25 deletions(-) diff --git a/src/Storage/Device.php b/src/Storage/Device.php index 9bccd279..c084589e 100644 --- a/src/Storage/Device.php +++ b/src/Storage/Device.php @@ -137,7 +137,7 @@ abstract public function read(string $path, int $offset = 0, int $length = null) * @param string $path * @param string $destination * @param Device $device - * @return string + * @return bool */ abstract public function transfer(string $path, string $destination, Device $device): bool; diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index 57155c7c..79d22e5b 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -82,7 +82,7 @@ public function getPath(string $filename, string $prefix = null): string */ public function upload(string $source, string $path, int $chunk = 1, int $chunks = 1, array &$metadata = []): int { - $this->createDirectoryToPath($path); + $this->createDirectory($path); //move_uploaded_file() verifies the file is not tampered with if ($chunks === 1) { @@ -94,7 +94,7 @@ public function upload(string $source, string $path, int $chunk = 1, int $chunks } $tmp = \dirname($path).DIRECTORY_SEPARATOR.'tmp_'.\basename($path).DIRECTORY_SEPARATOR.\basename($path).'_chunks.log'; - $this->createDirectoryToPath($tmp); + $this->createDirectory($tmp); if (! file_put_contents($tmp, "$chunk\n", FILE_APPEND)) { throw new Exception('Can\'t write chunk log '.$tmp); } @@ -137,7 +137,7 @@ public function upload(string $source, string $path, int $chunk = 1, int $chunks */ public function uploadData(string $data, string $path, string $contentType, int $chunk = 1, int $chunks = 1, array &$metadata = []): int { - $this->createDirectoryToPath($path); + $this->createDirectory($path); if ($chunks === 1) { if (! \file_put_contents($path, $data)) { @@ -148,7 +148,7 @@ public function uploadData(string $data, string $path, string $contentType, int } $tmp = \dirname($path).DIRECTORY_SEPARATOR.'tmp_'.\basename($path).DIRECTORY_SEPARATOR.\basename($path).'_chunks.log'; - $this->createDirectoryToPath($tmp); + $this->createDirectory($tmp); if (! file_put_contents($tmp, "$chunk\n", FILE_APPEND)) { throw new Exception('Can\'t write chunk log '.$tmp); } @@ -191,24 +191,6 @@ private function joinChunks(string $path, int $chunks) \unlink($tmp); } - /** - * Create Directory to Path - * - * Create's missing directory of the path, returns true on success and false on failure - * - * @param string path - * - * @throws Exception - */ - private function createDirectoryToPath(string $path): void - { - if (! \file_exists(\dirname($path))) { // Checks if directory path to file exists - if (! @\mkdir(\dirname($path), 0755, true)) { - throw new Exception('Can\'t create directory: '.\dirname($path)); - } - } - } - /** * Transfer * diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 3f78cd31..ef30466f 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -291,9 +291,8 @@ public function transfer(string $path, string $destination, Device $device): boo } $totalChunks = \ceil($size / $this->transferChunkSize); - $counter = 0; $metadata = ['content_type' => $contentType]; - for ($counter; $counter < $totalChunks; $counter++) { + for ($counter = 0; $counter < $totalChunks; $counter++) { $start = $counter * $this->transferChunkSize; $data = $this->read($path, $start, $this->transferChunkSize); $device->uploadData($data, $destination, $contentType, $counter + 1, $totalChunks, $metadata); From e22aaf64c915eb65910dd2c6689d3f5a6f7c8b23 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Fri, 3 Mar 2023 00:27:21 +0000 Subject: [PATCH 019/117] added description --- src/Storage/Device.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Storage/Device.php b/src/Storage/Device.php index c084589e..8b47c9ad 100644 --- a/src/Storage/Device.php +++ b/src/Storage/Device.php @@ -133,7 +133,8 @@ abstract public function read(string $path, int $offset = 0, int $length = null) /** * Transfer - * + * Transfer a file from current device to destination device. + * * @param string $path * @param string $destination * @param Device $device From 7eb73332d1ae900a0ff6ee79aab18c384ad61dd7 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Fri, 3 Mar 2023 00:45:59 +0000 Subject: [PATCH 020/117] fix create directory error --- src/Storage/Device/Local.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index 79d22e5b..80d2a4c4 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -82,7 +82,7 @@ public function getPath(string $filename, string $prefix = null): string */ public function upload(string $source, string $path, int $chunk = 1, int $chunks = 1, array &$metadata = []): int { - $this->createDirectory($path); + $this->createDirectory(\dirname($path)); //move_uploaded_file() verifies the file is not tampered with if ($chunks === 1) { @@ -94,7 +94,7 @@ public function upload(string $source, string $path, int $chunk = 1, int $chunks } $tmp = \dirname($path).DIRECTORY_SEPARATOR.'tmp_'.\basename($path).DIRECTORY_SEPARATOR.\basename($path).'_chunks.log'; - $this->createDirectory($tmp); + $this->createDirectory(\dirname($tmp)); if (! file_put_contents($tmp, "$chunk\n", FILE_APPEND)) { throw new Exception('Can\'t write chunk log '.$tmp); } @@ -137,7 +137,7 @@ public function upload(string $source, string $path, int $chunk = 1, int $chunks */ public function uploadData(string $data, string $path, string $contentType, int $chunk = 1, int $chunks = 1, array &$metadata = []): int { - $this->createDirectory($path); + $this->createDirectory(\dirname($path)); if ($chunks === 1) { if (! \file_put_contents($path, $data)) { @@ -148,7 +148,7 @@ public function uploadData(string $data, string $path, string $contentType, int } $tmp = \dirname($path).DIRECTORY_SEPARATOR.'tmp_'.\basename($path).DIRECTORY_SEPARATOR.\basename($path).'_chunks.log'; - $this->createDirectory($tmp); + $this->createDirectory(\dirname($tmp)); if (! file_put_contents($tmp, "$chunk\n", FILE_APPEND)) { throw new Exception('Can\'t write chunk log '.$tmp); } From 4ac630c18615bef692540a15606a8664a1b897c2 Mon Sep 17 00:00:00 2001 From: "Luke B. Silver" <22452787+loks0n@users.noreply.github.com> Date: Thu, 27 Apr 2023 12:27:18 +0100 Subject: [PATCH 021/117] fix: accept lowercase file extensions Cameras and other media sources often output uppercase extensions such as 'JPG'. These extensions should also be accepted. --- src/Storage/Validator/FileExt.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Storage/Validator/FileExt.php b/src/Storage/Validator/FileExt.php index 80506c2d..34d72288 100644 --- a/src/Storage/Validator/FileExt.php +++ b/src/Storage/Validator/FileExt.php @@ -46,6 +46,7 @@ public function getDescription(): string public function isValid($filename): bool { $ext = pathinfo($filename, PATHINFO_EXTENSION); + $ext = strtolower($ext) if (! in_array($ext, $this->allowed)) { return false; From 7b4f1aa9725378ccfa618aeeffb168b658aca0fc Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Thu, 27 Apr 2023 12:32:27 +0100 Subject: [PATCH 022/117] test: add test case --- tests/Storage/Validator/FileExtTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Storage/Validator/FileExtTest.php b/tests/Storage/Validator/FileExtTest.php index b3b6a69a..e7f4f4be 100644 --- a/tests/Storage/Validator/FileExtTest.php +++ b/tests/Storage/Validator/FileExtTest.php @@ -35,5 +35,6 @@ public function testValues() $this->assertEquals($this->object->isValid('file.tar.g'), false); $this->assertEquals($this->object->isValid('file.tar.gz'), true); $this->assertEquals($this->object->isValid('file.gz'), true); + $this->assertEquals($this->object->isValid('file.GIF'), true); } } From 6f6357fc96c2bca2f9954f5fe4dc1a12094a9711 Mon Sep 17 00:00:00 2001 From: "Luke B. Silver" <22452787+loks0n@users.noreply.github.com> Date: Fri, 28 Apr 2023 11:17:34 +0100 Subject: [PATCH 023/117] fix: missing semi --- src/Storage/Validator/FileExt.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storage/Validator/FileExt.php b/src/Storage/Validator/FileExt.php index 34d72288..ee121068 100644 --- a/src/Storage/Validator/FileExt.php +++ b/src/Storage/Validator/FileExt.php @@ -46,7 +46,7 @@ public function getDescription(): string public function isValid($filename): bool { $ext = pathinfo($filename, PATHINFO_EXTENSION); - $ext = strtolower($ext) + $ext = strtolower($ext); if (! in_array($ext, $this->allowed)) { return false; From d318c7000619cb8cda2f85429cb78fc56a6ee143 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 18 Jul 2023 09:11:20 +0000 Subject: [PATCH 024/117] fix formatting --- composer.lock | 248 +++++++++++------- src/Storage/Compression/Algorithms/XZ.php | 6 +- src/Storage/Device.php | 2 +- .../Storage/Compression/Algorithms/XZTest.php | 26 +- tests/Storage/Device/LocalTest.php | 2 +- 5 files changed, 168 insertions(+), 116 deletions(-) diff --git a/composer.lock b/composer.lock index 56f1adf2..f3d8f364 100644 --- a/composer.lock +++ b/composer.lock @@ -4,27 +4,28 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0e15ac0ae89a77c7420f825af10e33fc", + "content-hash": "31a62f29d84509b2ba01e75fd652d6ba", "packages": [ { "name": "utopia-php/framework", - "version": "0.27.0", + "version": "0.28.4", "source": { "type": "git", "url": "https://github.com/utopia-php/framework.git", - "reference": "b8d0447f5c98291d7759db05460ecced29a0f9ee" + "reference": "98c5469efe195aeecc63745dbf8e2f357f8cedac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/framework/zipball/b8d0447f5c98291d7759db05460ecced29a0f9ee", - "reference": "b8d0447f5c98291d7759db05460ecced29a0f9ee", + "url": "https://api.github.com/repos/utopia-php/framework/zipball/98c5469efe195aeecc63745dbf8e2f357f8cedac", + "reference": "98c5469efe195aeecc63745dbf8e2f357f8cedac", "shasum": "" }, "require": { - "php": ">=8.0.0" + "php": ">=8.0" }, "require-dev": { "laravel/pint": "^1.2", + "phpstan/phpstan": "1.9.x-dev", "phpunit/phpunit": "^9.5.25", "vimeo/psalm": "4.27.0" }, @@ -46,9 +47,9 @@ ], "support": { "issues": "https://github.com/utopia-php/framework/issues", - "source": "https://github.com/utopia-php/framework/tree/0.27.0" + "source": "https://github.com/utopia-php/framework/tree/0.28.4" }, - "time": "2023-01-29T05:36:17+00:00" + "time": "2023-06-03T14:09:22+00:00" } ], "packages-dev": [ @@ -475,18 +476,66 @@ }, "time": "2019-12-04T15:06:13+00:00" }, + { + "name": "doctrine/deprecations", + "version": "1.1.x-dev", + "source": { + "type": "git", + "url": "https://github.com/doctrine/deprecations.git", + "reference": "eac01fbdf4e4a3635169b056608730ec0930e188" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/eac01fbdf4e4a3635169b056608730ec0930e188", + "reference": "eac01fbdf4e4a3635169b056608730ec0930e188", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^9", + "phpstan/phpstan": "1.4.10 || 1.10.15", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "psalm/plugin-phpunit": "0.18.4", + "psr/log": "^1 || ^2 || ^3", + "vimeo/psalm": "4.30.0 || 5.12.0" + }, + "suggest": { + "psr/log": "Allows logging deprecations via PSR-3 logger implementation" + }, + "default-branch": true, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", + "homepage": "https://www.doctrine-project.org/", + "support": { + "issues": "https://github.com/doctrine/deprecations/issues", + "source": "https://github.com/doctrine/deprecations/tree/1.1.x" + }, + "time": "2023-06-07T19:57:14+00:00" + }, { "name": "doctrine/instantiator", "version": "2.0.x-dev", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "d6eef505a6c46e963e54bf73bb9de43cdea70821" + "reference": "3aa0a786dd096763a5e4be2cc3bacb774859552a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/d6eef505a6c46e963e54bf73bb9de43cdea70821", - "reference": "d6eef505a6c46e963e54bf73bb9de43cdea70821", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/3aa0a786dd096763a5e4be2cc3bacb774859552a", + "reference": "3aa0a786dd096763a5e4be2cc3bacb774859552a", "shasum": "" }, "require": { @@ -499,7 +548,7 @@ "phpbench/phpbench": "^1.2", "phpstan/phpstan": "^1.9.4", "phpstan/phpstan-phpunit": "^1.3", - "phpunit/phpunit": "^9.5.27", + "phpunit/phpunit": "^10.1.0", "vimeo/psalm": "^5.4" }, "default-branch": true, @@ -544,7 +593,7 @@ "type": "tidelift" } ], - "time": "2023-01-04T15:42:40+00:00" + "time": "2023-05-30T06:43:41+00:00" }, { "name": "felixfbecker/advanced-json-rpc", @@ -720,12 +769,12 @@ "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614" + "reference": "928a96f585b86224ebc78f8f09d0482cf15b04f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614", - "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/928a96f585b86224ebc78f8f09d0482cf15b04f5", + "reference": "928a96f585b86224ebc78f8f09d0482cf15b04f5", "shasum": "" }, "require": { @@ -733,11 +782,12 @@ }, "conflict": { "doctrine/collections": "<1.6.8", - "doctrine/common": "<2.13.3 || >=3,<3.2.2" + "doctrine/common": "<2.13.3 || >=3 <3.2.2" }, "require-dev": { "doctrine/collections": "^1.6.8", "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" }, "default-branch": true, @@ -764,7 +814,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" + "source": "https://github.com/myclabs/DeepCopy/tree/1.x" }, "funding": [ { @@ -772,7 +822,7 @@ "type": "tidelift" } ], - "time": "2022-03-03T13:19:32+00:00" + "time": "2023-03-08T17:24:01+00:00" }, { "name": "netresearch/jsonmapper", @@ -831,12 +881,12 @@ "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "570e980a201d8ed0236b0a62ddf2c9cbb2034039" + "reference": "19526a33fb561ef417e822e85f08a00db4059c17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/570e980a201d8ed0236b0a62ddf2c9cbb2034039", - "reference": "570e980a201d8ed0236b0a62ddf2c9cbb2034039", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/19526a33fb561ef417e822e85f08a00db4059c17", + "reference": "19526a33fb561ef417e822e85f08a00db4059c17", "shasum": "" }, "require": { @@ -878,9 +928,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.3" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.16.0" }, - "time": "2023-01-16T22:05:37+00:00" + "time": "2023-06-25T14:52:30+00:00" }, { "name": "openlss/lib-array2xml", @@ -941,12 +991,12 @@ "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", - "reference": "36d8a21e851a9512db2b086dc5ac2c61308f0138" + "reference": "67729272c564ab9f953c81f48db44e8b1cb1e1c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/36d8a21e851a9512db2b086dc5ac2c61308f0138", - "reference": "36d8a21e851a9512db2b086dc5ac2c61308f0138", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/67729272c564ab9f953c81f48db44e8b1cb1e1c3", + "reference": "67729272c564ab9f953c81f48db44e8b1cb1e1c3", "shasum": "" }, "require": { @@ -955,7 +1005,7 @@ "ext-phar": "*", "ext-xmlwriter": "*", "phar-io/version": "^3.0.1", - "php": "^7.2 || ^8.0" + "php": "^7.3 || ^8.0" }, "default-branch": true, "type": "library", @@ -1001,7 +1051,7 @@ "type": "github" } ], - "time": "2022-02-21T19:55:33+00:00" + "time": "2023-06-01T14:19:47+00:00" }, { "name": "phar-io/version", @@ -1113,12 +1163,12 @@ "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "566af9fb94c556de91562fcfcbc392f66680111b" + "reference": "7b217217725dc991a0ae7b995041cee1d5019561" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/566af9fb94c556de91562fcfcbc392f66680111b", - "reference": "566af9fb94c556de91562fcfcbc392f66680111b", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/7b217217725dc991a0ae7b995041cee1d5019561", + "reference": "7b217217725dc991a0ae7b995041cee1d5019561", "shasum": "" }, "require": { @@ -1169,7 +1219,7 @@ "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" }, - "time": "2022-11-19T20:28:46+00:00" + "time": "2023-03-12T10:50:44+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -1177,15 +1227,16 @@ "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "06f36c92b434ac686de06b6563e88046943bccbe" + "reference": "b2fe4d22a5426f38e014855322200b97b5362c0d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/06f36c92b434ac686de06b6563e88046943bccbe", - "reference": "06f36c92b434ac686de06b6563e88046943bccbe", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/b2fe4d22a5426f38e014855322200b97b5362c0d", + "reference": "b2fe4d22a5426f38e014855322200b97b5362c0d", "shasum": "" }, "require": { + "doctrine/deprecations": "^1.0", "php": "^7.4 || ^8.0", "phpdocumentor/reflection-common": "^2.0", "phpstan/phpdoc-parser": "^1.13" @@ -1225,28 +1276,30 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.x" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.2" }, - "time": "2022-12-16T10:25:14+00:00" + "time": "2023-05-30T18:13:47+00:00" }, { "name": "phpstan/phpdoc-parser", - "version": "1.16.1", + "version": "1.22.x-dev", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "e27e92d939e2e3636f0a1f0afaba59692c0bf571" + "reference": "2108d702baa4883362a8824def66b96733b8cf82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/e27e92d939e2e3636f0a1f0afaba59692c0bf571", - "reference": "e27e92d939e2e3636f0a1f0afaba59692c0bf571", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/2108d702baa4883362a8824def66b96733b8cf82", + "reference": "2108d702baa4883362a8824def66b96733b8cf82", "shasum": "" }, "require": { "php": "^7.2 || ^8.0" }, "require-dev": { + "doctrine/annotations": "^2.0", + "nikic/php-parser": "^4.15", "php-parallel-lint/php-parallel-lint": "^1.2", "phpstan/extension-installer": "^1.0", "phpstan/phpstan": "^1.5", @@ -1255,6 +1308,7 @@ "phpunit/phpunit": "^9.5", "symfony/process": "^5.2" }, + "default-branch": true, "type": "library", "autoload": { "psr-4": { @@ -1270,9 +1324,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.16.1" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.22.x" }, - "time": "2023-02-07T18:11:17+00:00" + "time": "2023-07-17T07:08:06+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1280,19 +1334,19 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "b5f3416da036fb951a557518e8304b3595ff966a" + "reference": "f1564623dc5330085a73cefcf824b48cdec997b2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/b5f3416da036fb951a557518e8304b3595ff966a", - "reference": "b5f3416da036fb951a557518e8304b3595ff966a", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f1564623dc5330085a73cefcf824b48cdec997b2", + "reference": "f1564623dc5330085a73cefcf824b48cdec997b2", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.14", + "nikic/php-parser": "^4.15", "php": ">=7.3", "phpunit/php-file-iterator": "^3.0.3", "phpunit/php-text-template": "^2.0.2", @@ -1307,8 +1361,8 @@ "phpunit/phpunit": "^9.3" }, "suggest": { - "ext-pcov": "*", - "ext-xdebug": "*" + "ext-pcov": "PHP extension that provides line coverage", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" }, "type": "library", "extra": { @@ -1341,6 +1395,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2" }, "funding": [ @@ -1349,7 +1404,7 @@ "type": "github" } ], - "time": "2023-02-18T16:27:54+00:00" + "time": "2023-07-17T04:56:01+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1598,12 +1653,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "c1bf2dd252dec994ee27d804c038a98fd0d1d940" + "reference": "19cadf73b15656502e34bc4fc00e197fcc94802c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c1bf2dd252dec994ee27d804c038a98fd0d1d940", - "reference": "c1bf2dd252dec994ee27d804c038a98fd0d1d940", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/19cadf73b15656502e34bc4fc00e197fcc94802c", + "reference": "19cadf73b15656502e34bc4fc00e197fcc94802c", "shasum": "" }, "require": { @@ -1636,8 +1691,8 @@ "sebastian/version": "^3.0.2" }, "suggest": { - "ext-soap": "*", - "ext-xdebug": "*" + "ext-soap": "To be able to generate mocks based on WSDL files", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" }, "bin": [ "phpunit" @@ -1676,6 +1731,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6" }, "funding": [ @@ -1692,7 +1748,7 @@ "type": "tidelift" } ], - "time": "2023-02-18T16:26:49+00:00" + "time": "2023-07-17T05:01:41+00:00" }, { "name": "psr/container", @@ -2098,16 +2154,16 @@ }, { "name": "sebastian/diff", - "version": "4.0.4", + "version": "4.0.x-dev", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" + "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", - "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/74be17022044ebaaecfdf0c5cd504fc9cd5a7131", + "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131", "shasum": "" }, "require": { @@ -2152,7 +2208,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/diff/tree/4.0" }, "funding": [ { @@ -2160,7 +2216,7 @@ "type": "github" } ], - "time": "2020-10-26T13:10:38+00:00" + "time": "2023-05-07T05:35:17+00:00" }, { "name": "sebastian/environment", @@ -2604,12 +2660,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "e1157eac767e4dc4ae40dd9aab7fb4de6e56bd32" + "reference": "20bdda85c7c585ab265c0c37ec052a019bae29c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/e1157eac767e4dc4ae40dd9aab7fb4de6e56bd32", - "reference": "e1157eac767e4dc4ae40dd9aab7fb4de6e56bd32", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/20bdda85c7c585ab265c0c37ec052a019bae29c4", + "reference": "20bdda85c7c585ab265c0c37ec052a019bae29c4", "shasum": "" }, "require": { @@ -2651,7 +2707,7 @@ "type": "github" } ], - "time": "2023-02-08T06:53:39+00:00" + "time": "2023-03-25T08:11:39+00:00" }, { "name": "sebastian/type", @@ -2768,12 +2824,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "bc04b7a3c23fd36e4b165afe7947b3d00989677b" + "reference": "560fc3ed7a43e6d30ea94a07d77f9a60b8ed0fb8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/bc04b7a3c23fd36e4b165afe7947b3d00989677b", - "reference": "bc04b7a3c23fd36e4b165afe7947b3d00989677b", + "url": "https://api.github.com/repos/symfony/console/zipball/560fc3ed7a43e6d30ea94a07d77f9a60b8ed0fb8", + "reference": "560fc3ed7a43e6d30ea94a07d77f9a60b8ed0fb8", "shasum": "" }, "require": { @@ -2838,7 +2894,7 @@ "homepage": "https://symfony.com", "keywords": [ "cli", - "command line", + "command-line", "console", "terminal" ], @@ -2859,7 +2915,7 @@ "type": "tidelift" } ], - "time": "2023-02-14T14:10:40+00:00" + "time": "2023-05-26T05:13:16+00:00" }, { "name": "symfony/deprecation-contracts", @@ -2867,12 +2923,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "1ee04c65529dea5d8744774d474e7cbd2f1206d3" + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/1ee04c65529dea5d8744774d474e7cbd2f1206d3", - "reference": "1ee04c65529dea5d8744774d474e7cbd2f1206d3", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", "shasum": "" }, "require": { @@ -2882,7 +2938,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.3-dev" + "dev-main": "3.4-dev" }, "thanks": { "name": "symfony/contracts", @@ -2911,7 +2967,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.2.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.3.0" }, "funding": [ { @@ -2927,7 +2983,7 @@ "type": "tidelift" } ], - "time": "2022-11-25T10:21:52+00:00" + "time": "2023-05-23T14:45:45+00:00" }, { "name": "symfony/polyfill-ctype", @@ -3433,12 +3489,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "aac98028c69df04ee77eb69b96b86ee51fbf4b75" + "reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/aac98028c69df04ee77eb69b96b86ee51fbf4b75", - "reference": "aac98028c69df04ee77eb69b96b86ee51fbf4b75", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/40da9cc13ec349d9e4966ce18b5fbcd724ab10a4", + "reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4", "shasum": "" }, "require": { @@ -3448,14 +3504,11 @@ "conflict": { "ext-psr": "<1.1|>=2" }, - "suggest": { - "symfony/service-implementation": "" - }, "default-branch": true, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.3-dev" + "dev-main": "3.4-dev" }, "thanks": { "name": "symfony/contracts", @@ -3495,7 +3548,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.2.0" + "source": "https://github.com/symfony/service-contracts/tree/v3.3.0" }, "funding": [ { @@ -3511,20 +3564,20 @@ "type": "tidelift" } ], - "time": "2022-11-25T10:21:52+00:00" + "time": "2023-05-23T14:45:45+00:00" }, { "name": "symfony/string", - "version": "6.3.x-dev", + "version": "6.4.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "6515bacc98212164f10db4371fa70ee7b8c70b80" + "reference": "34267d7e5422c9c41808b4e0d251d2414e9d7742" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/6515bacc98212164f10db4371fa70ee7b8c70b80", - "reference": "6515bacc98212164f10db4371fa70ee7b8c70b80", + "url": "https://api.github.com/repos/symfony/string/zipball/34267d7e5422c9c41808b4e0d251d2414e9d7742", + "reference": "34267d7e5422c9c41808b4e0d251d2414e9d7742", "shasum": "" }, "require": { @@ -3538,11 +3591,11 @@ "symfony/translation-contracts": "<2.5" }, "require-dev": { - "symfony/error-handler": "^5.4|^6.0", - "symfony/http-client": "^5.4|^6.0", - "symfony/intl": "^6.2", + "symfony/error-handler": "^5.4|^6.0|^7.0", + "symfony/http-client": "^5.4|^6.0|^7.0", + "symfony/intl": "^6.2|^7.0", "symfony/translation-contracts": "^2.5|^3.0", - "symfony/var-exporter": "^5.4|^6.0" + "symfony/var-exporter": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -3581,7 +3634,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/6.3" + "source": "https://github.com/symfony/string/tree/6.4" }, "funding": [ { @@ -3597,7 +3650,7 @@ "type": "tidelift" } ], - "time": "2023-02-14T09:04:20+00:00" + "time": "2023-07-05T09:40:08+00:00" }, { "name": "theseer/tokenizer", @@ -3919,6 +3972,7 @@ "ext-fileinfo": "*", "ext-zlib": "*", "ext-zstd": "*", + "ext-xz": "*", "ext-brotli": "*", "ext-lz4": "*", "ext-snappy": "*", diff --git a/src/Storage/Compression/Algorithms/XZ.php b/src/Storage/Compression/Algorithms/XZ.php index 3bd2c386..aaa79fae 100644 --- a/src/Storage/Compression/Algorithms/XZ.php +++ b/src/Storage/Compression/Algorithms/XZ.php @@ -17,8 +17,7 @@ public function getName(): string /** * Compress. * - * @param string $data - * + * @param string $data * @return string */ public function compress(string $data): string @@ -29,8 +28,7 @@ public function compress(string $data): string /** * Decompress. * - * @param string $data - * + * @param string $data * @return string */ public function decompress(string $data): string diff --git a/src/Storage/Device.php b/src/Storage/Device.php index 8b47c9ad..23027d94 100644 --- a/src/Storage/Device.php +++ b/src/Storage/Device.php @@ -134,7 +134,7 @@ abstract public function read(string $path, int $offset = 0, int $length = null) /** * Transfer * Transfer a file from current device to destination device. - * + * * @param string $path * @param string $destination * @param Device $device diff --git a/tests/Storage/Compression/Algorithms/XZTest.php b/tests/Storage/Compression/Algorithms/XZTest.php index 6fec876e..2b55ee01 100644 --- a/tests/Storage/Compression/Algorithms/XZTest.php +++ b/tests/Storage/Compression/Algorithms/XZTest.php @@ -2,8 +2,8 @@ namespace Utopia\Tests\Storage\Compression\Algorithms; -use Utopia\Storage\Compression\Algorithms\XZ; use PHPUnit\Framework\TestCase; +use Utopia\Storage\Compression\Algorithms\XZ; class XZTest extends TestCase { @@ -22,7 +22,7 @@ public function testName() { $this->assertEquals($this->object->getName(), 'xz'); } - + public function testCompressDecompressWithText() { $demo = 'This is a demo string'; @@ -33,13 +33,13 @@ public function testCompressDecompressWithText() $this->assertEquals($demoSize, 21); $this->assertEquals($dataSize, 80); - + $this->assertEquals($this->object->decompress($data), $demo); } - + public function testCompressDecompressWithJPGImage() { - $demo = \file_get_contents(__DIR__ . '/../../../resources/disk-a/kitten-1.jpg'); + $demo = \file_get_contents(__DIR__.'/../../../resources/disk-a/kitten-1.jpg'); $demoSize = mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); @@ -47,18 +47,18 @@ public function testCompressDecompressWithJPGImage() $this->assertEquals($demoSize, 599639); $this->assertEquals($dataSize, 599432); - + $this->assertGreaterThan($dataSize, $demoSize); - + $data = $this->object->decompress($data); $dataSize = mb_strlen($data, '8bit'); - + $this->assertEquals($dataSize, 599639); } - + public function testCompressDecompressWithPNGImage() { - $demo = \file_get_contents(__DIR__ . '/../../../resources/disk-b/kitten-1.png'); + $demo = \file_get_contents(__DIR__.'/../../../resources/disk-b/kitten-1.png'); $demoSize = mb_strlen($demo, '8bit'); $data = $this->object->compress($demo); @@ -66,12 +66,12 @@ public function testCompressDecompressWithPNGImage() $this->assertEquals($demoSize, 3038056); $this->assertEquals($dataSize, 2981000); - + $this->assertGreaterThan($dataSize, $demoSize); - + $data = $this->object->decompress($data); $dataSize = mb_strlen($data, '8bit'); - + $this->assertEquals($dataSize, 3038056); } } diff --git a/tests/Storage/Device/LocalTest.php b/tests/Storage/Device/LocalTest.php index dc7657fd..f5ead457 100644 --- a/tests/Storage/Device/LocalTest.php +++ b/tests/Storage/Device/LocalTest.php @@ -291,7 +291,7 @@ public function testTransferSmall() $this->object->delete($path); $device->delete($destination); } - + public function testDeletePath() { // Test Single Object From 2ee3666511b3da604e7e4d66263f1dbea9f6fb04 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 19 Jul 2023 07:14:15 +0000 Subject: [PATCH 025/117] remove linter as it's added to Github action --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c7438e66..b9c4ab2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,5 +32,4 @@ install: script: - docker ps - docker-compose exec tests vendor/bin/phpunit --configuration phpunit.xml --debug --testsuite unit - - docker-compose exec tests vendor/bin/phpunit --configuration phpunit.xml --debug --testsuite e2e - - docker-compose exec tests vendor/bin/psalm --show-info=true \ No newline at end of file + - docker-compose exec tests vendor/bin/phpunit --configuration phpunit.xml --debug --testsuite e2e \ No newline at end of file From 27d60cd64a3255814698125a128fce1742476b4e Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 25 Jul 2023 07:32:22 +0000 Subject: [PATCH 026/117] remove the tmp directory as well --- src/Storage/Device/Local.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index b0bf68af..0e4a0bb5 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -189,6 +189,7 @@ private function joinChunks(string $path, int $chunks) \unlink($part); } \unlink($tmp); + \unlink(dirname($tmp)); } /** From ae190865088491d7f8aa3fc63e6906efe6e42295 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 25 Jul 2023 07:40:02 +0000 Subject: [PATCH 027/117] remove directory --- src/Storage/Device/Local.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index 0e4a0bb5..d3b0db99 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -189,7 +189,7 @@ private function joinChunks(string $path, int $chunks) \unlink($part); } \unlink($tmp); - \unlink(dirname($tmp)); + \rmdir(dirname($tmp)); } /** From 0833dff2e0cf68ccd5d413a9a3b203d78f131cec Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 8 Aug 2023 02:47:38 +0000 Subject: [PATCH 028/117] add system library --- composer.json | 3 +- composer.lock | 349 +++++++++++++++++++++++++++++--------------------- 2 files changed, 205 insertions(+), 147 deletions(-) diff --git a/composer.json b/composer.json index 46d12e03..3dde33f0 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,8 @@ "ext-lz4": "*", "ext-snappy": "*", "php": ">=8.0", - "utopia-php/framework": "0.*.*" + "utopia-php/framework": "0.*.*", + "utopia-php/system": "0.*.*" }, "require-dev": { "phpunit/phpunit": "^9.3", diff --git a/composer.lock b/composer.lock index f3d8f364..54da72ab 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,86 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "31a62f29d84509b2ba01e75fd652d6ba", + "content-hash": "024174312546d59cde20dd0dd4e6186d", "packages": [ + { + "name": "laravel/pint", + "version": "v1.2.1", + "source": { + "type": "git", + "url": "https://github.com/laravel/pint.git", + "reference": "e60e2112ee779ce60f253695b273d1646a17d6f1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/pint/zipball/e60e2112ee779ce60f253695b273d1646a17d6f1", + "reference": "e60e2112ee779ce60f253695b273d1646a17d6f1", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-mbstring": "*", + "ext-tokenizer": "*", + "ext-xml": "*", + "php": "^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.11.0", + "illuminate/view": "^9.32.0", + "laravel-zero/framework": "^9.2.0", + "mockery/mockery": "^1.5.1", + "nunomaduro/larastan": "^2.2.0", + "nunomaduro/termwind": "^1.14.0", + "pestphp/pest": "^1.22.1" + }, + "bin": [ + "builds/pint" + ], + "type": "project", + "autoload": { + "psr-4": { + "App\\": "app/", + "Database\\Seeders\\": "database/seeders/", + "Database\\Factories\\": "database/factories/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "An opinionated code formatter for PHP.", + "homepage": "https://laravel.com", + "keywords": [ + "format", + "formatter", + "lint", + "linter", + "php" + ], + "support": { + "issues": "https://github.com/laravel/pint/issues", + "source": "https://github.com/laravel/pint" + }, + "time": "2022-11-29T16:25:20+00:00" + }, { "name": "utopia-php/framework", - "version": "0.28.4", + "version": "0.30.0", "source": { "type": "git", "url": "https://github.com/utopia-php/framework.git", - "reference": "98c5469efe195aeecc63745dbf8e2f357f8cedac" + "reference": "0969d429997996ceade53e477fce31221b415651" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/framework/zipball/98c5469efe195aeecc63745dbf8e2f357f8cedac", - "reference": "98c5469efe195aeecc63745dbf8e2f357f8cedac", + "url": "https://api.github.com/repos/utopia-php/framework/zipball/0969d429997996ceade53e477fce31221b415651", + "reference": "0969d429997996ceade53e477fce31221b415651", "shasum": "" }, "require": { @@ -25,9 +91,9 @@ }, "require-dev": { "laravel/pint": "^1.2", - "phpstan/phpstan": "1.9.x-dev", - "phpunit/phpunit": "^9.5.25", - "vimeo/psalm": "4.27.0" + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9.5.25" }, "type": "library", "autoload": { @@ -47,9 +113,66 @@ ], "support": { "issues": "https://github.com/utopia-php/framework/issues", - "source": "https://github.com/utopia-php/framework/tree/0.28.4" + "source": "https://github.com/utopia-php/framework/tree/0.30.0" }, - "time": "2023-06-03T14:09:22+00:00" + "time": "2023-08-07T07:55:48+00:00" + }, + { + "name": "utopia-php/system", + "version": "0.7.0", + "source": { + "type": "git", + "url": "https://github.com/utopia-php/system.git", + "reference": "d385e9521ca3f68aa007ec1cadd11c4dbd871b90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/utopia-php/system/zipball/d385e9521ca3f68aa007ec1cadd11c4dbd871b90", + "reference": "d385e9521ca3f68aa007ec1cadd11c4dbd871b90", + "shasum": "" + }, + "require": { + "laravel/pint": "1.2.*", + "php": ">=8.0.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3", + "squizlabs/php_codesniffer": "^3.6", + "vimeo/psalm": "4.0.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Utopia\\System\\": "src/System" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Eldad Fux", + "email": "eldad@appwrite.io" + }, + { + "name": "Torsten Dittmann", + "email": "torsten@appwrite.io" + } + ], + "description": "A simple library for obtaining information about the host's system.", + "keywords": [ + "framework", + "php", + "system", + "upf", + "utopia" + ], + "support": { + "issues": "https://github.com/utopia-php/system/issues", + "source": "https://github.com/utopia-php/system/tree/0.7.0" + }, + "time": "2023-08-07T09:34:26+00:00" } ], "packages-dev": [ @@ -482,12 +605,12 @@ "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "eac01fbdf4e4a3635169b056608730ec0930e188" + "reference": "bdaa697ed9c7f5ee2f7d3b5f9c2a6f2519523cd9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/eac01fbdf4e4a3635169b056608730ec0930e188", - "reference": "eac01fbdf4e4a3635169b056608730ec0930e188", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/bdaa697ed9c7f5ee2f7d3b5f9c2a6f2519523cd9", + "reference": "bdaa697ed9c7f5ee2f7d3b5f9c2a6f2519523cd9", "shasum": "" }, "require": { @@ -522,7 +645,7 @@ "issues": "https://github.com/doctrine/deprecations/issues", "source": "https://github.com/doctrine/deprecations/tree/1.1.x" }, - "time": "2023-06-07T19:57:14+00:00" + "time": "2023-07-29T16:12:19+00:00" }, { "name": "doctrine/instantiator", @@ -530,12 +653,12 @@ "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "3aa0a786dd096763a5e4be2cc3bacb774859552a" + "reference": "40fc8fcd149f6ccff851e767c3fc5ded4e6a96c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/3aa0a786dd096763a5e4be2cc3bacb774859552a", - "reference": "3aa0a786dd096763a5e4be2cc3bacb774859552a", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/40fc8fcd149f6ccff851e767c3fc5ded4e6a96c0", + "reference": "40fc8fcd149f6ccff851e767c3fc5ded4e6a96c0", "shasum": "" }, "require": { @@ -593,7 +716,7 @@ "type": "tidelift" } ], - "time": "2023-05-30T06:43:41+00:00" + "time": "2023-07-30T10:00:15+00:00" }, { "name": "felixfbecker/advanced-json-rpc", @@ -697,84 +820,18 @@ }, "time": "2022-06-19T17:15:06+00:00" }, - { - "name": "laravel/pint", - "version": "v1.2.1", - "source": { - "type": "git", - "url": "https://github.com/laravel/pint.git", - "reference": "e60e2112ee779ce60f253695b273d1646a17d6f1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/e60e2112ee779ce60f253695b273d1646a17d6f1", - "reference": "e60e2112ee779ce60f253695b273d1646a17d6f1", - "shasum": "" - }, - "require": { - "ext-json": "*", - "ext-mbstring": "*", - "ext-tokenizer": "*", - "ext-xml": "*", - "php": "^8.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^3.11.0", - "illuminate/view": "^9.32.0", - "laravel-zero/framework": "^9.2.0", - "mockery/mockery": "^1.5.1", - "nunomaduro/larastan": "^2.2.0", - "nunomaduro/termwind": "^1.14.0", - "pestphp/pest": "^1.22.1" - }, - "bin": [ - "builds/pint" - ], - "type": "project", - "autoload": { - "psr-4": { - "App\\": "app/", - "Database\\Seeders\\": "database/seeders/", - "Database\\Factories\\": "database/factories/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nuno Maduro", - "email": "enunomaduro@gmail.com" - } - ], - "description": "An opinionated code formatter for PHP.", - "homepage": "https://laravel.com", - "keywords": [ - "format", - "formatter", - "lint", - "linter", - "php" - ], - "support": { - "issues": "https://github.com/laravel/pint/issues", - "source": "https://github.com/laravel/pint" - }, - "time": "2022-11-29T16:25:20+00:00" - }, { "name": "myclabs/deep-copy", "version": "1.x-dev", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "928a96f585b86224ebc78f8f09d0482cf15b04f5" + "reference": "f6f48cfecf52ab791fe18cc1b11d6345512dc4b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/928a96f585b86224ebc78f8f09d0482cf15b04f5", - "reference": "928a96f585b86224ebc78f8f09d0482cf15b04f5", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/f6f48cfecf52ab791fe18cc1b11d6345512dc4b8", + "reference": "f6f48cfecf52ab791fe18cc1b11d6345512dc4b8", "shasum": "" }, "require": { @@ -822,7 +879,7 @@ "type": "tidelift" } ], - "time": "2023-03-08T17:24:01+00:00" + "time": "2023-07-30T10:01:33+00:00" }, { "name": "netresearch/jsonmapper", @@ -881,12 +938,12 @@ "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "19526a33fb561ef417e822e85f08a00db4059c17" + "reference": "cfc54e30a4f5e5af5f9d9ce86697cfcc5f7e7c24" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/19526a33fb561ef417e822e85f08a00db4059c17", - "reference": "19526a33fb561ef417e822e85f08a00db4059c17", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/cfc54e30a4f5e5af5f9d9ce86697cfcc5f7e7c24", + "reference": "cfc54e30a4f5e5af5f9d9ce86697cfcc5f7e7c24", "shasum": "" }, "require": { @@ -928,9 +985,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.16.0" + "source": "https://github.com/nikic/PHP-Parser/tree/4.x" }, - "time": "2023-06-25T14:52:30+00:00" + "time": "2023-07-30T21:38:32+00:00" }, { "name": "openlss/lib-array2xml", @@ -1227,12 +1284,12 @@ "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "b2fe4d22a5426f38e014855322200b97b5362c0d" + "reference": "07100e65d09fd50608d649fc656cae1c921a2495" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/b2fe4d22a5426f38e014855322200b97b5362c0d", - "reference": "b2fe4d22a5426f38e014855322200b97b5362c0d", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/07100e65d09fd50608d649fc656cae1c921a2495", + "reference": "07100e65d09fd50608d649fc656cae1c921a2495", "shasum": "" }, "require": { @@ -1276,22 +1333,22 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.2" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.x" }, - "time": "2023-05-30T18:13:47+00:00" + "time": "2023-07-20T19:57:33+00:00" }, { "name": "phpstan/phpdoc-parser", - "version": "1.22.x-dev", + "version": "1.23.x-dev", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "2108d702baa4883362a8824def66b96733b8cf82" + "reference": "846ae76eef31c6d7790fac9bc399ecee45160b26" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/2108d702baa4883362a8824def66b96733b8cf82", - "reference": "2108d702baa4883362a8824def66b96733b8cf82", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/846ae76eef31c6d7790fac9bc399ecee45160b26", + "reference": "846ae76eef31c6d7790fac9bc399ecee45160b26", "shasum": "" }, "require": { @@ -1324,9 +1381,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.22.x" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.23.1" }, - "time": "2023-07-17T07:08:06+00:00" + "time": "2023-08-03T16:32:59+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1334,12 +1391,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "f1564623dc5330085a73cefcf824b48cdec997b2" + "reference": "9e1baee3a7525530f5600035759ce754a8b3750b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f1564623dc5330085a73cefcf824b48cdec997b2", - "reference": "f1564623dc5330085a73cefcf824b48cdec997b2", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/9e1baee3a7525530f5600035759ce754a8b3750b", + "reference": "9e1baee3a7525530f5600035759ce754a8b3750b", "shasum": "" }, "require": { @@ -1404,7 +1461,7 @@ "type": "github" } ], - "time": "2023-07-17T04:56:01+00:00" + "time": "2023-08-02T09:00:29+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1653,12 +1710,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "19cadf73b15656502e34bc4fc00e197fcc94802c" + "reference": "6904cfa5f4a6211e759de8ef36fb51fc939a83fa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/19cadf73b15656502e34bc4fc00e197fcc94802c", - "reference": "19cadf73b15656502e34bc4fc00e197fcc94802c", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6904cfa5f4a6211e759de8ef36fb51fc939a83fa", + "reference": "6904cfa5f4a6211e759de8ef36fb51fc939a83fa", "shasum": "" }, "require": { @@ -1748,7 +1805,7 @@ "type": "tidelift" } ], - "time": "2023-07-17T05:01:41+00:00" + "time": "2023-08-02T08:56:58+00:00" }, { "name": "psr/container", @@ -2364,12 +2421,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2" + "reference": "bde739e7565280bda77be70044ac1047bc007e34" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2", - "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bde739e7565280bda77be70044ac1047bc007e34", + "reference": "bde739e7565280bda77be70044ac1047bc007e34", "shasum": "" }, "require": { @@ -2412,7 +2469,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0" }, "funding": [ { @@ -2420,7 +2477,7 @@ "type": "github" } ], - "time": "2022-02-14T08:28:10+00:00" + "time": "2023-08-02T09:26:13+00:00" }, { "name": "sebastian/lines-of-code", @@ -2824,12 +2881,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "560fc3ed7a43e6d30ea94a07d77f9a60b8ed0fb8" + "reference": "b504a3d266ad2bb632f196c0936ef2af5ff6e273" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/560fc3ed7a43e6d30ea94a07d77f9a60b8ed0fb8", - "reference": "560fc3ed7a43e6d30ea94a07d77f9a60b8ed0fb8", + "url": "https://api.github.com/repos/symfony/console/zipball/b504a3d266ad2bb632f196c0936ef2af5ff6e273", + "reference": "b504a3d266ad2bb632f196c0936ef2af5ff6e273", "shasum": "" }, "require": { @@ -2915,7 +2972,7 @@ "type": "tidelift" } ], - "time": "2023-05-26T05:13:16+00:00" + "time": "2023-07-19T20:11:33+00:00" }, { "name": "symfony/deprecation-contracts", @@ -2987,7 +3044,7 @@ }, { "name": "symfony/polyfill-ctype", - "version": "dev-main", + "version": "1.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", @@ -3050,7 +3107,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/main" + "source": "https://github.com/symfony/polyfill-ctype/tree/1.x" }, "funding": [ { @@ -3070,7 +3127,7 @@ }, { "name": "symfony/polyfill-intl-grapheme", - "version": "dev-main", + "version": "1.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", @@ -3132,7 +3189,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/main" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/1.x" }, "funding": [ { @@ -3152,7 +3209,7 @@ }, { "name": "symfony/polyfill-intl-normalizer", - "version": "dev-main", + "version": "1.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", @@ -3217,7 +3274,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/main" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/1.x" }, "funding": [ { @@ -3237,16 +3294,16 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "dev-main", + "version": "1.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "f9c7affe77a00ae32ca127ca6833d034e6d33f25" + "reference": "42292d99c55abe617799667f454222c54c60e229" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f9c7affe77a00ae32ca127ca6833d034e6d33f25", - "reference": "f9c7affe77a00ae32ca127ca6833d034e6d33f25", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229", + "reference": "42292d99c55abe617799667f454222c54c60e229", "shasum": "" }, "require": { @@ -3301,7 +3358,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/main" + "source": "https://github.com/symfony/polyfill-mbstring/tree/1.x" }, "funding": [ { @@ -3317,11 +3374,11 @@ "type": "tidelift" } ], - "time": "2023-01-30T17:25:47+00:00" + "time": "2023-07-28T09:04:16+00:00" }, { "name": "symfony/polyfill-php73", - "version": "dev-main", + "version": "1.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", @@ -3381,7 +3438,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/main" + "source": "https://github.com/symfony/polyfill-php73/tree/1.x" }, "funding": [ { @@ -3401,7 +3458,7 @@ }, { "name": "symfony/polyfill-php80", - "version": "dev-main", + "version": "1.x-dev", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", @@ -3465,7 +3522,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/main" + "source": "https://github.com/symfony/polyfill-php80/tree/1.x" }, "funding": [ { @@ -3489,12 +3546,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4" + "reference": "a4025a1c812c231d88ed0780e866b0cc644f4a84" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/40da9cc13ec349d9e4966ce18b5fbcd724ab10a4", - "reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/a4025a1c812c231d88ed0780e866b0cc644f4a84", + "reference": "a4025a1c812c231d88ed0780e866b0cc644f4a84", "shasum": "" }, "require": { @@ -3548,7 +3605,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.3.0" + "source": "https://github.com/symfony/service-contracts/tree/main" }, "funding": [ { @@ -3564,7 +3621,7 @@ "type": "tidelift" } ], - "time": "2023-05-23T14:45:45+00:00" + "time": "2023-07-29T13:12:44+00:00" }, { "name": "symfony/string", @@ -3572,12 +3629,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "34267d7e5422c9c41808b4e0d251d2414e9d7742" + "reference": "fe9228ba417441e16f31d36ddad2b3076135f453" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/34267d7e5422c9c41808b4e0d251d2414e9d7742", - "reference": "34267d7e5422c9c41808b4e0d251d2414e9d7742", + "url": "https://api.github.com/repos/symfony/string/zipball/fe9228ba417441e16f31d36ddad2b3076135f453", + "reference": "fe9228ba417441e16f31d36ddad2b3076135f453", "shasum": "" }, "require": { @@ -3650,7 +3707,7 @@ "type": "tidelift" } ], - "time": "2023-07-05T09:40:08+00:00" + "time": "2023-07-27T06:52:43+00:00" }, { "name": "theseer/tokenizer", From 47dc2227957c716dc7a4f24f35b4c5325e565bb4 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 8 Aug 2023 02:51:07 +0000 Subject: [PATCH 029/117] check file size against free memory --- src/Storage/Device/S3.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 2c771719..56781595 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -5,6 +5,7 @@ use Exception; use Utopia\Storage\Device; use Utopia\Storage\Storage; +use Utopia\System\System; class S3 extends Device { @@ -223,6 +224,12 @@ public function getPath(string $filename, string $prefix = null): string */ public function upload(string $source, string $path, int $chunk = 1, int $chunks = 1, array &$metadata = []): int { + $fileSize = \filesize($source); + $freeMemory = System::getMemoryFree(); + + if($fileSize > $freeMemory) { + throw new Exception('Trying to load file larger than available memory. Please use chunked upload.'); + } return $this->uploadData(\file_get_contents($source), $path, \mime_content_type($source), $chunk, $chunks, $metadata); } From 79605177db196993fc19235cf61a5c7b757c7d4b Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 8 Aug 2023 02:51:52 +0000 Subject: [PATCH 030/117] format --- src/Storage/Device/S3.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 56781595..2e30250f 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -227,9 +227,10 @@ public function upload(string $source, string $path, int $chunk = 1, int $chunks $fileSize = \filesize($source); $freeMemory = System::getMemoryFree(); - if($fileSize > $freeMemory) { + if ($fileSize > $freeMemory) { throw new Exception('Trying to load file larger than available memory. Please use chunked upload.'); } + return $this->uploadData(\file_get_contents($source), $path, \mime_content_type($source), $chunk, $chunks, $metadata); } From 25f6b80b3063b85d7c9483be85f7b6ffea4c1edd Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 8 Aug 2023 02:58:34 +0000 Subject: [PATCH 031/117] improve --- src/Storage/Device/Local.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index d3b0db99..6d5c0f13 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -215,9 +215,8 @@ public function transfer(string $path, string $destination, Device $device): boo } $totalChunks = \ceil($size / $this->transferChunkSize); - $counter = 0; $metadata = ['content_type' => $contentType]; - for ($counter; $counter < $totalChunks; $counter++) { + for ($counter = 0; $counter < $totalChunks; $counter++) { $start = $counter * $this->transferChunkSize; $data = $this->read($path, $start, $this->transferChunkSize); $device->uploadData($data, $destination, $contentType, $counter + 1, $totalChunks, $metadata); From b49f24b90dedfda45df65a2fae7ae8eeed552de1 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 8 Aug 2023 13:42:03 +0545 Subject: [PATCH 032/117] revert back free memory check --- src/Storage/Device/S3.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 2e30250f..04c9095d 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -224,13 +224,6 @@ public function getPath(string $filename, string $prefix = null): string */ public function upload(string $source, string $path, int $chunk = 1, int $chunks = 1, array &$metadata = []): int { - $fileSize = \filesize($source); - $freeMemory = System::getMemoryFree(); - - if ($fileSize > $freeMemory) { - throw new Exception('Trying to load file larger than available memory. Please use chunked upload.'); - } - return $this->uploadData(\file_get_contents($source), $path, \mime_content_type($source), $chunk, $chunks, $metadata); } From cef63e2d76156c2069c98ccd1430ebac5df3a35c Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 8 Aug 2023 08:09:59 +0000 Subject: [PATCH 033/117] fix format --- src/Storage/Device/S3.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 04c9095d..2c771719 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -5,7 +5,6 @@ use Exception; use Utopia\Storage\Device; use Utopia\Storage\Storage; -use Utopia\System\System; class S3 extends Device { From 69bd2f38d0e0bd953b85af59eb546d6c04d1f282 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 10 Aug 2023 06:08:04 +0000 Subject: [PATCH 034/117] github action for test --- .github/workflows/tests.yml | 39 +++++++++++++++++++++++++++++ tests/Storage/Device/LinodeTest.php | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..6272eb11 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,39 @@ +name: "Tests" + +on: [pull_request] +jobs: + tests: + name: Unit & E2E + runs-on: ubuntu-latest + + steps: + - name: Checkout Repo + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build image + uses: docker/build-push-action@v3 + with: + context: . + push: false + load: true + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Start storage + env: + DO_ACCESS_KEY: ${{ secrets.DO_ACCESS_KEY }} + DO_SECRET: ${{ secrets.DO_SECRET }} + LINODE_ACCESS_KEY: ${{ secrets.LINODE_ACCESS_KEY }} + LINODE_SECRET: ${{ secrets.LINODE_SECRET }} + run: | + docker compose up -d + sleep 10 + + - name: Unit Tests + run: docker compose exec -T tests vendor/bin/phpunit --configuration phpunit.xml --debug --testsuite unit + + - name: E2E Tests + run: docker compose exec -T tests vendor/bin/phpunit --configuration phpunit.xml --debug --testsuite e2e diff --git a/tests/Storage/Device/LinodeTest.php b/tests/Storage/Device/LinodeTest.php index 397e62bc..b10ecf85 100644 --- a/tests/Storage/Device/LinodeTest.php +++ b/tests/Storage/Device/LinodeTest.php @@ -12,7 +12,7 @@ protected function init(): void $this->root = '/root'; $key = $_SERVER['LINODE_ACCESS_KEY'] ?? ''; $secret = $_SERVER['LINODE_SECRET'] ?? ''; - $bucket = 'everly-test'; + $bucket = 'storage-test'; $this->object = new Linode($this->root, $key, $secret, $bucket, Linode::EU_CENTRAL_1, Linode::ACL_PRIVATE); } From a9d96f0826e63d358c8c113af6c8326e4c8f8cc4 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 10 Aug 2023 06:17:31 +0000 Subject: [PATCH 035/117] doctor in tests --- .github/workflows/tests.yml | 6 ++++++ tests/Storage/Device/S3Test.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6272eb11..5e8ca2d7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -31,6 +31,12 @@ jobs: run: | docker compose up -d sleep 10 + + - name: Doctor + run: | + docker compose logs + docker ps + docker network ls - name: Unit Tests run: docker compose exec -T tests vendor/bin/phpunit --configuration phpunit.xml --debug --testsuite unit diff --git a/tests/Storage/Device/S3Test.php b/tests/Storage/Device/S3Test.php index d8e05c3b..9c55f217 100644 --- a/tests/Storage/Device/S3Test.php +++ b/tests/Storage/Device/S3Test.php @@ -12,7 +12,7 @@ protected function init(): void $this->root = '/root'; $key = $_SERVER['S3_ACCESS_KEY'] ?? ''; $secret = $_SERVER['S3_SECRET'] ?? ''; - $bucket = 'appwrite-test-bucket'; + $bucket = 'utopia-storage-test'; $this->object = new S3($this->root, $key, $secret, $bucket, S3::EU_WEST_1, S3::ACL_PRIVATE); } From 84ee9c11934bda3e24bed921a85b46c438bd78ab Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 10 Aug 2023 06:22:49 +0000 Subject: [PATCH 036/117] build without buildx --- .github/workflows/tests.yml | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5e8ca2d7..9ca92154 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,22 +7,10 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout Repo + - name: Checkout repo uses: actions/checkout@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Build image - uses: docker/build-push-action@v3 - with: - context: . - push: false - load: true - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Start storage + + - name: Start test stack env: DO_ACCESS_KEY: ${{ secrets.DO_ACCESS_KEY }} DO_SECRET: ${{ secrets.DO_SECRET }} @@ -30,7 +18,7 @@ jobs: LINODE_SECRET: ${{ secrets.LINODE_SECRET }} run: | docker compose up -d - sleep 10 + sleep 1 - name: Doctor run: | From f413bbefd1847e41b57103bc7418b8fcc8b8cad8 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 10 Aug 2023 06:24:25 +0000 Subject: [PATCH 037/117] build cache --- .github/workflows/tests.yml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9ca92154..5e8ca2d7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,10 +7,22 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout repo + - name: Checkout Repo uses: actions/checkout@v3 - - - name: Start test stack + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build image + uses: docker/build-push-action@v3 + with: + context: . + push: false + load: true + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Start storage env: DO_ACCESS_KEY: ${{ secrets.DO_ACCESS_KEY }} DO_SECRET: ${{ secrets.DO_SECRET }} @@ -18,7 +30,7 @@ jobs: LINODE_SECRET: ${{ secrets.LINODE_SECRET }} run: | docker compose up -d - sleep 1 + sleep 10 - name: Doctor run: | From 6d8acf2fd644d4deeab9f0e2a10e6c44f09b65d2 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 10 Aug 2023 06:25:24 +0000 Subject: [PATCH 038/117] modify doctor --- .github/workflows/tests.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5e8ca2d7..4fc9e5f1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,9 +34,8 @@ jobs: - name: Doctor run: | - docker compose logs + docker compose logs tests docker ps - docker network ls - name: Unit Tests run: docker compose exec -T tests vendor/bin/phpunit --configuration phpunit.xml --debug --testsuite unit From 522c5f456dcdd43a527fe406360f4d983a2a3461 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 10 Aug 2023 06:28:01 +0000 Subject: [PATCH 039/117] ls to see container --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4fc9e5f1..b1adfe02 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -36,6 +36,7 @@ jobs: run: | docker compose logs tests docker ps + docker compose exec -T tests ls - name: Unit Tests run: docker compose exec -T tests vendor/bin/phpunit --configuration phpunit.xml --debug --testsuite unit From bc62d46e5aa557a9511563c8ace6336aebc2e192 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 10 Aug 2023 06:32:54 +0000 Subject: [PATCH 040/117] modify docker file --- .github/workflows/tests.yml | 1 - docker-compose.yml | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b1adfe02..4fc9e5f1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -36,7 +36,6 @@ jobs: run: | docker compose logs tests docker ps - docker compose exec -T tests ls - name: Unit Tests run: docker compose exec -T tests vendor/bin/phpunit --configuration phpunit.xml --debug --testsuite unit diff --git a/docker-compose.yml b/docker-compose.yml index e6af4bb2..01155a5e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,9 @@ services: build: context: . volumes: - - ./:/usr/src/code + - ./src:/usr/src/code/src + - ./tests:/usr/src/code/tests + - ./phpunit.xml:/usr/src/code/phpunit.xml environment: - S3_ACCESS_KEY - S3_SECRET From f6636da07eb52cf31c6a5e185cea5e9a718775c6 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 10 Aug 2023 06:35:15 +0000 Subject: [PATCH 041/117] add s3 keys --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4fc9e5f1..9bfe2d8b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,6 +28,8 @@ jobs: DO_SECRET: ${{ secrets.DO_SECRET }} LINODE_ACCESS_KEY: ${{ secrets.LINODE_ACCESS_KEY }} LINODE_SECRET: ${{ secrets.LINODE_SECRET }} + S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} + S3_SECRET: ${{ secrets.S3_SECRET }} run: | docker compose up -d sleep 10 From 22d2590d7ad92df9be9924a90daad9c00bcd8d40 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 10 Aug 2023 08:10:35 +0000 Subject: [PATCH 042/117] fix test region --- tests/Storage/Device/S3Test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Storage/Device/S3Test.php b/tests/Storage/Device/S3Test.php index 9c55f217..2b0255c8 100644 --- a/tests/Storage/Device/S3Test.php +++ b/tests/Storage/Device/S3Test.php @@ -14,7 +14,7 @@ protected function init(): void $secret = $_SERVER['S3_SECRET'] ?? ''; $bucket = 'utopia-storage-test'; - $this->object = new S3($this->root, $key, $secret, $bucket, S3::EU_WEST_1, S3::ACL_PRIVATE); + $this->object = new S3($this->root, $key, $secret, $bucket, S3::EU_CENTRAL_1, S3::ACL_PRIVATE); } /** From bf588bc57da62137de248f4f072df2a99290e709 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 10 Aug 2023 08:25:39 +0000 Subject: [PATCH 043/117] fix test.credentials --- tests/Storage/Device/LocalTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Storage/Device/LocalTest.php b/tests/Storage/Device/LocalTest.php index f5ead457..9db0510c 100644 --- a/tests/Storage/Device/LocalTest.php +++ b/tests/Storage/Device/LocalTest.php @@ -257,9 +257,9 @@ public function testTransferLarge($path) $key = $_SERVER['S3_ACCESS_KEY'] ?? ''; $secret = $_SERVER['S3_SECRET'] ?? ''; - $bucket = 'appwrite-test-bucket'; + $bucket = 'utopia-storage-test'; - $device = new S3('/root', $key, $secret, $bucket, S3::EU_WEST_1, S3::ACL_PRIVATE); + $device = new S3('/root', $key, $secret, $bucket, S3::EU_CENTRAL_1, S3::ACL_PRIVATE); $destination = $device->getPath('largefile.mp4'); $this->assertTrue($this->object->transfer($path, $destination, $device)); @@ -276,9 +276,9 @@ public function testTransferSmall() $key = $_SERVER['S3_ACCESS_KEY'] ?? ''; $secret = $_SERVER['S3_SECRET'] ?? ''; - $bucket = 'appwrite-test-bucket'; + $bucket = 'utopia-storage-test'; - $device = new S3('/root', $key, $secret, $bucket, S3::EU_WEST_1, S3::ACL_PRIVATE); + $device = new S3('/root', $key, $secret, $bucket, S3::EU_CENTRAL_1, S3::ACL_PRIVATE); $path = $this->object->getPath('text-for-read.txt'); $this->object->write($path, 'Hello World'); From ea17610d6975b690ca670bdbaa4e2e35478ca674 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sat, 12 Aug 2023 00:58:36 +0000 Subject: [PATCH 044/117] remove travis config --- .travis.yml | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b9c4ab2d..00000000 --- a/.travis.yml +++ /dev/null @@ -1,35 +0,0 @@ -dist: focal - -arch: - - amd64 - -os: linux - -language: shell - -notifications: - email: - - team@appwrite.io - -before_script: docker run --rm --interactive --tty --volume "$(pwd)":/app composer update --ignore-platform-reqs --optimize-autoloader --no-plugins --no-scripts --prefer-dist - -before_install: - - curl -fsSL https://get.docker.com | sh - - echo '{"experimental":"enabled"}' | sudo tee /etc/docker/daemon.json - - mkdir -p $HOME/.docker - - echo '{"experimental":"enabled"}' | sudo tee $HOME/.docker/config.json - - sudo service docker start - - > - if [ ! -z "${DOCKERHUB_PULL_USERNAME:-}" ]; then - echo "${DOCKERHUB_PULL_PASSWORD}" | docker login --username "${DOCKERHUB_PULL_USERNAME}" --password-stdin - fi - - docker --version - -install: - - docker-compose up -d - - sleep 10 - -script: - - docker ps - - docker-compose exec tests vendor/bin/phpunit --configuration phpunit.xml --debug --testsuite unit - - docker-compose exec tests vendor/bin/phpunit --configuration phpunit.xml --debug --testsuite e2e \ No newline at end of file From 62303deb8932a9885290167cfc73904ea5d78818 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sat, 12 Aug 2023 01:35:56 +0000 Subject: [PATCH 045/117] refactor test --- .github/workflows/tests.yml | 26 ++++++++++++++++++++++++-- tests/Storage/Device/BackblazeTest.php | 2 +- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9bfe2d8b..0906886a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,9 +1,13 @@ name: "Tests" +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: [pull_request] jobs: - tests: - name: Unit & E2E + build: + name: Build & Unit runs-on: ubuntu-latest steps: @@ -44,3 +48,21 @@ jobs: - name: E2E Tests run: docker compose exec -T tests vendor/bin/phpunit --configuration phpunit.xml --debug --testsuite e2e + e2e_test: + name: E2E Test + runs-on: ubuntu-latest + needs: build + strategy: + fail-fast: false + matrix: + devices: [BlackblazeTest, DOSpacesTest, LinodeTest, LocalTest, S3Test, WasabiTest] + + steps: + - name: checkout + uses: actions/checkout@v3 + - name: Start storage + run: | + docker compose up -d + sleep 10 + - name: Run ${{matrix.devices}} + run: docker compose exec -T vendor/bin/phpunit tests/Storage/Device/${{matrix.devices}}.php diff --git a/tests/Storage/Device/BackblazeTest.php b/tests/Storage/Device/BackblazeTest.php index 159bcb0f..91ce2f8f 100644 --- a/tests/Storage/Device/BackblazeTest.php +++ b/tests/Storage/Device/BackblazeTest.php @@ -12,7 +12,7 @@ protected function init(): void $this->root = '/root'; $key = $_SERVER['BACKBLAZE_ACCESS_KEY'] ?? ''; $secret = $_SERVER['BACKBLAZE_SECRET'] ?? ''; - $bucket = 'backblaze-demo'; + $bucket = 'utopia-storage-test'; $this->object = new Backblaze($this->root, $key, $secret, $bucket, Backblaze::US_WEST_004, Backblaze::ACL_PRIVATE); } From 52b187c153e3df20e4bf11b9358a2ee52f90524d Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sat, 12 Aug 2023 01:41:55 +0000 Subject: [PATCH 046/117] remove e2e test from build workflow --- .github/workflows/tests.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0906886a..83fb5a62 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -45,9 +45,7 @@ jobs: - name: Unit Tests run: docker compose exec -T tests vendor/bin/phpunit --configuration phpunit.xml --debug --testsuite unit - - - name: E2E Tests - run: docker compose exec -T tests vendor/bin/phpunit --configuration phpunit.xml --debug --testsuite e2e + e2e_test: name: E2E Test runs-on: ubuntu-latest From 61fa79214fa4b644f36759a9ac6b93b9249108da Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sat, 12 Aug 2023 01:51:47 +0000 Subject: [PATCH 047/117] fix test issues --- .github/workflows/tests.yml | 10 ++-------- docker-compose.yml | 1 + 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 83fb5a62..503e409b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,17 +23,11 @@ jobs: context: . push: false load: true + tags: storage-dev cache-from: type=gha cache-to: type=gha,mode=max - name: Start storage - env: - DO_ACCESS_KEY: ${{ secrets.DO_ACCESS_KEY }} - DO_SECRET: ${{ secrets.DO_SECRET }} - LINODE_ACCESS_KEY: ${{ secrets.LINODE_ACCESS_KEY }} - LINODE_SECRET: ${{ secrets.LINODE_SECRET }} - S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} - S3_SECRET: ${{ secrets.S3_SECRET }} run: | docker compose up -d sleep 10 @@ -63,4 +57,4 @@ jobs: docker compose up -d sleep 10 - name: Run ${{matrix.devices}} - run: docker compose exec -T vendor/bin/phpunit tests/Storage/Device/${{matrix.devices}}.php + run: docker compose exec -T tests vendor/bin/phpunit tests/Storage/Device/${{matrix.devices}}.php diff --git a/docker-compose.yml b/docker-compose.yml index 01155a5e..4cd5e9f7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,7 @@ version: '3.1' services: tests: container_name: tests + image: storage-dev build: context: . volumes: From 8fdf481f4ae5b75f2b98e49334300962376f7d81 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sat, 12 Aug 2023 01:56:41 +0000 Subject: [PATCH 048/117] fix test environments --- .github/workflows/tests.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 503e409b..c54abcd3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,6 +28,17 @@ jobs: cache-to: type=gha,mode=max - name: Start storage + env: + DO_ACCESS_KEY: ${{ secrets.DO_ACCESS_KEY }} + DO_SECRET: ${{ secrets.DO_SECRET }} + LINODE_ACCESS_KEY: ${{ secrets.LINODE_ACCESS_KEY }} + LINODE_SECRET: ${{ secrets.LINODE_SECRET }} + S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} + S3_SECRET: ${{ secrets.S3_SECRET }} + WASABI_ACCESS_KEY: ${{ secrets.WASABI_ACCESS_KEY }} + WASABI_SECRET: ${{ secrets.WASABI_SECRET }} + BLACKBLAZE_ACCESS_KEY: ${{ secrets.BLACKBLAZE_ACCESS_KEY }} + BLACKBLAZE_SECRET: ${{ secrets.BLACKBLAZE_SECRET }} run: | docker compose up -d sleep 10 @@ -53,6 +64,17 @@ jobs: - name: checkout uses: actions/checkout@v3 - name: Start storage + env: + DO_ACCESS_KEY: ${{ secrets.DO_ACCESS_KEY }} + DO_SECRET: ${{ secrets.DO_SECRET }} + LINODE_ACCESS_KEY: ${{ secrets.LINODE_ACCESS_KEY }} + LINODE_SECRET: ${{ secrets.LINODE_SECRET }} + S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} + S3_SECRET: ${{ secrets.S3_SECRET }} + WASABI_ACCESS_KEY: ${{ secrets.WASABI_ACCESS_KEY }} + WASABI_SECRET: ${{ secrets.WASABI_SECRET }} + BLACKBLAZE_ACCESS_KEY: ${{ secrets.BLACKBLAZE_ACCESS_KEY }} + BLACKBLAZE_SECRET: ${{ secrets.BLACKBLAZE_SECRET }} run: | docker compose up -d sleep 10 From 8ce26079f9f0737de99e506c3ec65c70fe194ecc Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sat, 12 Aug 2023 02:00:51 +0000 Subject: [PATCH 049/117] fix typo --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c54abcd3..adc23b67 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -58,7 +58,7 @@ jobs: strategy: fail-fast: false matrix: - devices: [BlackblazeTest, DOSpacesTest, LinodeTest, LocalTest, S3Test, WasabiTest] + devices: [BackblazeTest, DOSpacesTest, LinodeTest, LocalTest, S3Test, WasabiTest] steps: - name: checkout From 274f56eeba585b3616df6465227b52e3b4124607 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sat, 12 Aug 2023 02:02:32 +0000 Subject: [PATCH 050/117] fix linode bucket region --- tests/Storage/Device/LinodeTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Storage/Device/LinodeTest.php b/tests/Storage/Device/LinodeTest.php index b10ecf85..95118739 100644 --- a/tests/Storage/Device/LinodeTest.php +++ b/tests/Storage/Device/LinodeTest.php @@ -14,7 +14,7 @@ protected function init(): void $secret = $_SERVER['LINODE_SECRET'] ?? ''; $bucket = 'storage-test'; - $this->object = new Linode($this->root, $key, $secret, $bucket, Linode::EU_CENTRAL_1, Linode::ACL_PRIVATE); + $this->object = new Linode($this->root, $key, $secret, $bucket, Linode::AP_SOUTH_1, Linode::ACL_PRIVATE); } protected function getAdapterName(): string From 29e54ea116964c9e04a368274708cb630e8878b2 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sat, 12 Aug 2023 02:10:33 +0000 Subject: [PATCH 051/117] fix typo in keys --- .github/workflows/tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index adc23b67..43d7ca7e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -37,8 +37,8 @@ jobs: S3_SECRET: ${{ secrets.S3_SECRET }} WASABI_ACCESS_KEY: ${{ secrets.WASABI_ACCESS_KEY }} WASABI_SECRET: ${{ secrets.WASABI_SECRET }} - BLACKBLAZE_ACCESS_KEY: ${{ secrets.BLACKBLAZE_ACCESS_KEY }} - BLACKBLAZE_SECRET: ${{ secrets.BLACKBLAZE_SECRET }} + BACKBLAZE_ACCESS_KEY: ${{ secrets.BACKBLAZE_ACCESS_KEY }} + BACKBLAZE_SECRET: ${{ secrets.BACKBLAZE_SECRET }} run: | docker compose up -d sleep 10 @@ -73,8 +73,8 @@ jobs: S3_SECRET: ${{ secrets.S3_SECRET }} WASABI_ACCESS_KEY: ${{ secrets.WASABI_ACCESS_KEY }} WASABI_SECRET: ${{ secrets.WASABI_SECRET }} - BLACKBLAZE_ACCESS_KEY: ${{ secrets.BLACKBLAZE_ACCESS_KEY }} - BLACKBLAZE_SECRET: ${{ secrets.BLACKBLAZE_SECRET }} + BACKBLAZE_ACCESS_KEY: ${{ secrets.BACKBLAZE_ACCESS_KEY }} + BACKBLAZE_SECRET: ${{ secrets.BACKBLAZE_SECRET }} run: | docker compose up -d sleep 10 From bf55cf0a03f6bb104864d44af1a63d33a298cf5a Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sat, 12 Aug 2023 02:16:53 +0000 Subject: [PATCH 052/117] fix bucket region --- tests/Storage/Device/LinodeTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Storage/Device/LinodeTest.php b/tests/Storage/Device/LinodeTest.php index b10ecf85..95118739 100644 --- a/tests/Storage/Device/LinodeTest.php +++ b/tests/Storage/Device/LinodeTest.php @@ -14,7 +14,7 @@ protected function init(): void $secret = $_SERVER['LINODE_SECRET'] ?? ''; $bucket = 'storage-test'; - $this->object = new Linode($this->root, $key, $secret, $bucket, Linode::EU_CENTRAL_1, Linode::ACL_PRIVATE); + $this->object = new Linode($this->root, $key, $secret, $bucket, Linode::AP_SOUTH_1, Linode::ACL_PRIVATE); } protected function getAdapterName(): string From cfdbc7809854396994955ba3288ab696db4149bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sun, 20 Aug 2023 11:56:08 +0000 Subject: [PATCH 053/117] Expose getFiles in local device --- src/Storage/Device/Local.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index 6d5c0f13..7f3190eb 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -503,7 +503,7 @@ public function getPartitionTotalSpace(): float * @param string $dir Directory to scan * @return string[] */ - private function getFiles(string $dir): array + public function getFiles(string $dir): array { if (! (\str_ends_with($dir, DIRECTORY_SEPARATOR))) { $dir .= DIRECTORY_SEPARATOR; From d23bf23b7f30598be41db21cda667edce14d002d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 21 Aug 2023 08:12:05 +0000 Subject: [PATCH 054/117] add tests, update adapter with new method --- src/Storage/Device.php | 8 ++++++++ src/Storage/Device/Local.php | 2 +- src/Storage/Device/S3.php | 11 +++++++++++ tests/Storage/Device/LocalTest.php | 18 ++++++++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/Storage/Device.php b/src/Storage/Device.php index 23027d94..fdc73483 100644 --- a/src/Storage/Device.php +++ b/src/Storage/Device.php @@ -267,6 +267,14 @@ abstract public function getPartitionFreeSpace(): float; */ abstract public function getPartitionTotalSpace(): float; + /** + * Get all files and directories inside a directory. + * + * @param string $dir Directory to scan + * @return string[] + */ + abstract public function getFiles(string $dir): array; + /** * Get the absolute path by resolving strings like ../, .., //, /\ and so on. * diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index 7f3190eb..b4b3eecb 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -498,7 +498,7 @@ public function getPartitionTotalSpace(): float } /** - * Get all files inside a directory. + * Get all files and directories inside a directory. * * @param string $dir Directory to scan * @return string[] diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 2c771719..625056b5 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -653,6 +653,17 @@ public function getPartitionTotalSpace(): float return -1; } + /** + * Get all files and directories inside a directory. + * + * @param string $dir Directory to scan + * @return string[] + */ + public function getFiles(string $dir): array + { + throw new Exception('Not implemented.'); + } + /** * Get file info * diff --git a/tests/Storage/Device/LocalTest.php b/tests/Storage/Device/LocalTest.php index 9db0510c..ab106a8b 100644 --- a/tests/Storage/Device/LocalTest.php +++ b/tests/Storage/Device/LocalTest.php @@ -323,4 +323,22 @@ public function testDeletePath() $this->assertEquals(false, $this->object->exists($path2)); $this->assertEquals(false, $this->object->exists($path3)); } + + public function testGetFiles() + { + $files = $this->object->getFiles(DIRECTORY_SEPARATOR); + $count = \count($files); + + $path = $this->object->getPath('new-file.txt'); + $this->object->write($path, 'Hello World'); + + $path = $this->object->getPath('new-file-two.txt'); + $this->object->write($path, 'Hello World'); + + $files = $this->object->getFiles(DIRECTORY_SEPARATOR); + $count2 = \count($files); + + $this->assertEquals($count2, $count + 2); + + } } From bd4c9935232a31c8f97d40261646556805fc1940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 21 Aug 2023 08:36:25 +0000 Subject: [PATCH 055/117] Fix new test --- tests/Storage/Device/LocalTest.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/tests/Storage/Device/LocalTest.php b/tests/Storage/Device/LocalTest.php index ab106a8b..af679efe 100644 --- a/tests/Storage/Device/LocalTest.php +++ b/tests/Storage/Device/LocalTest.php @@ -326,19 +326,17 @@ public function testDeletePath() public function testGetFiles() { - $files = $this->object->getFiles(DIRECTORY_SEPARATOR); - $count = \count($files); + $dir = DIRECTORY_SEPARATOR.'get-files-test'; - $path = $this->object->getPath('new-file.txt'); - $this->object->write($path, 'Hello World'); - - $path = $this->object->getPath('new-file-two.txt'); - $this->object->write($path, 'Hello World'); + $this->assertTrue($this->object->createDirectory($dir)); - $files = $this->object->getFiles(DIRECTORY_SEPARATOR); - $count2 = \count($files); + $files = $this->object->getFiles($dir); + $this->assertEquals(0, \count($files)); - $this->assertEquals($count2, $count + 2); + $this->object->write($dir.DIRECTORY_SEPARATOR.'new-file.txt', 'Hello World'); + $this->object->write($dir.DIRECTORY_SEPARATOR.'new-file-two.txt', 'Hello World'); + $files = $this->object->getFiles($dir); + $this->assertEquals(2, \count($files)); } } From 6167c5fe5a8703e06b370d488d2cea8260ccc31a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 21 Aug 2023 08:49:02 +0000 Subject: [PATCH 056/117] Fix nested deletePath --- src/Storage/Device/Local.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index b4b3eecb..1ef5b6c1 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -348,21 +348,25 @@ public function delete(string $path, bool $recursive = false): bool */ public function deletePath(string $path): bool { - $path = realpath($this->getRoot().DIRECTORY_SEPARATOR.$path); + $path = realpath($this->getRoot() . DIRECTORY_SEPARATOR . $path); - if (\is_dir($path)) { - $files = $this->getFiles($path); + if (!file_exists($path) || is_dir($path)) { + return false; + } - foreach ($files as $file) { + $files = $this->getFiles($path); + + foreach ($files as $file) { + if(is_dir($file)) { + $this->deletePath($file); + } else { $this->delete($file, true); } - - \rmdir($path); - - return true; } - return false; + \rmdir($path); + + return true; } /** From ace0d954d72b9e86ee56f47c5786b58ebbcdd1d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 21 Aug 2023 08:49:12 +0000 Subject: [PATCH 057/117] Linter fix --- src/Storage/Device/Local.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index 1ef5b6c1..cfa421e5 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -348,16 +348,16 @@ public function delete(string $path, bool $recursive = false): bool */ public function deletePath(string $path): bool { - $path = realpath($this->getRoot() . DIRECTORY_SEPARATOR . $path); + $path = realpath($this->getRoot().DIRECTORY_SEPARATOR.$path); - if (!file_exists($path) || is_dir($path)) { + if (! file_exists($path) || is_dir($path)) { return false; } $files = $this->getFiles($path); foreach ($files as $file) { - if(is_dir($file)) { + if (is_dir($file)) { $this->deletePath($file); } else { $this->delete($file, true); From 74ad4ec3e5b47ff1e47808a6ddc8a30c437add81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 21 Aug 2023 08:52:14 +0000 Subject: [PATCH 058/117] Fix bug in deletePath --- src/Storage/Device/Local.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index cfa421e5..a08fe60e 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -350,7 +350,7 @@ public function deletePath(string $path): bool { $path = realpath($this->getRoot().DIRECTORY_SEPARATOR.$path); - if (! file_exists($path) || is_dir($path)) { + if (! file_exists($path) || ! is_dir($path)) { return false; } From 1dfdf99fe92512b8aa0f17c1100bdaf41751a327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 21 Aug 2023 08:56:30 +0000 Subject: [PATCH 059/117] Add test for nested delete changes --- tests/Storage/Device/LocalTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/Storage/Device/LocalTest.php b/tests/Storage/Device/LocalTest.php index af679efe..b341a82c 100644 --- a/tests/Storage/Device/LocalTest.php +++ b/tests/Storage/Device/LocalTest.php @@ -339,4 +339,21 @@ public function testGetFiles() $files = $this->object->getFiles($dir); $this->assertEquals(2, \count($files)); } + + public function testNestedDeletePath() + { + $dir = DIRECTORY_SEPARATOR.'nested-delete-path-test'; + $dir2 = $dir.DIRECTORY_SEPARATOR.'dir2'; + $dir3 = $dir2.DIRECTORY_SEPARATOR.'dir3'; + + $this->assertTrue($this->object->createDirectory($dir)); + $this->object->write($dir.DIRECTORY_SEPARATOR.'new-file.txt', 'Hello World'); + $this->assertTrue($this->object->createDirectory($dir2)); + $this->object->write($dir2.DIRECTORY_SEPARATOR.'new-file-2.txt', 'Hello World'); + $this->assertTrue($this->object->createDirectory($dir3)); + $this->object->write($dir3.DIRECTORY_SEPARATOR.'new-file-3.txt', 'Hello World'); + + $this->assertTrue($this->object->deletePath($dir)); + $this->assertFalse($this->object->exists($dir)); + } } From 0b2ada49a204031148d25ce85889ccb7c7394e23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 21 Aug 2023 11:00:50 +0000 Subject: [PATCH 060/117] fix nested deletePath tests --- src/Storage/Device/Local.php | 2 +- tests/Storage/Device/LocalTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index a08fe60e..6ef23b63 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -358,7 +358,7 @@ public function deletePath(string $path): bool foreach ($files as $file) { if (is_dir($file)) { - $this->deletePath($file); + $this->deletePath(\ltrim($file, $this->getRoot().DIRECTORY_SEPARATOR)); } else { $this->delete($file, true); } diff --git a/tests/Storage/Device/LocalTest.php b/tests/Storage/Device/LocalTest.php index b341a82c..a2156b6a 100644 --- a/tests/Storage/Device/LocalTest.php +++ b/tests/Storage/Device/LocalTest.php @@ -342,7 +342,7 @@ public function testGetFiles() public function testNestedDeletePath() { - $dir = DIRECTORY_SEPARATOR.'nested-delete-path-test'; + $dir = $this->object->getPath('nested-delete-path-test'); $dir2 = $dir.DIRECTORY_SEPARATOR.'dir2'; $dir3 = $dir2.DIRECTORY_SEPARATOR.'dir3'; @@ -353,7 +353,7 @@ public function testNestedDeletePath() $this->assertTrue($this->object->createDirectory($dir3)); $this->object->write($dir3.DIRECTORY_SEPARATOR.'new-file-3.txt', 'Hello World'); - $this->assertTrue($this->object->deletePath($dir)); + $this->assertTrue($this->object->deletePath('nested-delete-path-test')); $this->assertFalse($this->object->exists($dir)); } } From 3949d9faae2735dd860ec16d543669fe80883998 Mon Sep 17 00:00:00 2001 From: fogelito Date: Wed, 23 Aug 2023 10:53:47 +0300 Subject: [PATCH 061/117] testMoveIdenticalName --- composer.lock | 56 +++++++++++++++++------------------ src/Storage/Device.php | 15 +++++++--- src/Storage/Device/Local.php | 9 ++++-- tests/Storage/S3Base.php | 13 ++++++++ tests/Storage/StorageTest.php | 17 +++++++++++ 5 files changed, 76 insertions(+), 34 deletions(-) diff --git a/composer.lock b/composer.lock index 54da72ab..3dafebac 100644 --- a/composer.lock +++ b/composer.lock @@ -938,12 +938,12 @@ "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "cfc54e30a4f5e5af5f9d9ce86697cfcc5f7e7c24" + "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/cfc54e30a4f5e5af5f9d9ce86697cfcc5f7e7c24", - "reference": "cfc54e30a4f5e5af5f9d9ce86697cfcc5f7e7c24", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", + "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", "shasum": "" }, "require": { @@ -985,9 +985,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/4.x" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.17.1" }, - "time": "2023-07-30T21:38:32+00:00" + "time": "2023-08-13T19:53:39+00:00" }, { "name": "openlss/lib-array2xml", @@ -1284,12 +1284,12 @@ "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "07100e65d09fd50608d649fc656cae1c921a2495" + "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/07100e65d09fd50608d649fc656cae1c921a2495", - "reference": "07100e65d09fd50608d649fc656cae1c921a2495", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", + "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", "shasum": "" }, "require": { @@ -1333,9 +1333,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.x" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.3" }, - "time": "2023-07-20T19:57:33+00:00" + "time": "2023-08-12T11:01:26+00:00" }, { "name": "phpstan/phpdoc-parser", @@ -1343,12 +1343,12 @@ "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "846ae76eef31c6d7790fac9bc399ecee45160b26" + "reference": "e540adcd37d57d1f46e2b6e172d6140d005226cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/846ae76eef31c6d7790fac9bc399ecee45160b26", - "reference": "846ae76eef31c6d7790fac9bc399ecee45160b26", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/e540adcd37d57d1f46e2b6e172d6140d005226cb", + "reference": "e540adcd37d57d1f46e2b6e172d6140d005226cb", "shasum": "" }, "require": { @@ -1381,9 +1381,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.23.1" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.23.x" }, - "time": "2023-08-03T16:32:59+00:00" + "time": "2023-08-16T11:40:53+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1391,12 +1391,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "9e1baee3a7525530f5600035759ce754a8b3750b" + "reference": "a74e6341296fe533cb69c8c94193afc7537443ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/9e1baee3a7525530f5600035759ce754a8b3750b", - "reference": "9e1baee3a7525530f5600035759ce754a8b3750b", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/a74e6341296fe533cb69c8c94193afc7537443ec", + "reference": "a74e6341296fe533cb69c8c94193afc7537443ec", "shasum": "" }, "require": { @@ -1461,7 +1461,7 @@ "type": "github" } ], - "time": "2023-08-02T09:00:29+00:00" + "time": "2023-08-21T05:57:35+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1710,12 +1710,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "6904cfa5f4a6211e759de8ef36fb51fc939a83fa" + "reference": "6c24b9dd8390a031a5490a2443fff1958522b49a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6904cfa5f4a6211e759de8ef36fb51fc939a83fa", - "reference": "6904cfa5f4a6211e759de8ef36fb51fc939a83fa", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6c24b9dd8390a031a5490a2443fff1958522b49a", + "reference": "6c24b9dd8390a031a5490a2443fff1958522b49a", "shasum": "" }, "require": { @@ -1805,7 +1805,7 @@ "type": "tidelift" } ], - "time": "2023-08-02T08:56:58+00:00" + "time": "2023-08-21T05:56:05+00:00" }, { "name": "psr/container", @@ -2881,12 +2881,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "b504a3d266ad2bb632f196c0936ef2af5ff6e273" + "reference": "f4f71842f24c2023b91237c72a365306f3c58827" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/b504a3d266ad2bb632f196c0936ef2af5ff6e273", - "reference": "b504a3d266ad2bb632f196c0936ef2af5ff6e273", + "url": "https://api.github.com/repos/symfony/console/zipball/f4f71842f24c2023b91237c72a365306f3c58827", + "reference": "f4f71842f24c2023b91237c72a365306f3c58827", "shasum": "" }, "require": { @@ -2972,7 +2972,7 @@ "type": "tidelift" } ], - "time": "2023-07-19T20:11:33+00:00" + "time": "2023-08-07T06:12:30+00:00" }, { "name": "symfony/deprecation-contracts", @@ -4036,5 +4036,5 @@ "php": ">=8.0" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.2.0" } diff --git a/src/Storage/Device.php b/src/Storage/Device.php index fdc73483..2f55f5e7 100644 --- a/src/Storage/Device.php +++ b/src/Storage/Device.php @@ -2,6 +2,8 @@ namespace Utopia\Storage; +use Exception; + abstract class Device { /** @@ -90,7 +92,7 @@ abstract public function getPath(string $filename, string $prefix = null): strin * @param array $metadata * @return int * - * @throws \Exception + * @throws Exception */ abstract public function upload(string $source, string $path, int $chunk = 1, int $chunks = 1, array &$metadata = []): int; @@ -108,7 +110,7 @@ abstract public function upload(string $source, string $path, int $chunk = 1, in * @param array $metadata * @return int * - * @throws \Exception + * @throws Exception */ abstract public function uploadData(string $data, string $path, string $contentType, int $chunk = 1, int $chunks = 1, array &$metadata = []): int; @@ -156,12 +158,17 @@ abstract public function write(string $path, string $data, string $contentType): * * @see http://php.net/manual/en/function.filesize.php * - * @param string $source - * @param string $target + * @param string $source + * @param string $target * @return bool + * @throws Exception */ public function move(string $source, string $target): bool { + if($source === $target){ + Throw new Exception('Source and target can not be identical!'); + } + if ($this->transfer($source, $target, $this)) { return $this->delete($source); } diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index 6ef23b63..ffff135e 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -295,12 +295,17 @@ public function write(string $path, string $data, string $contentType = ''): boo * * @see http://php.net/manual/en/function.filesize.php * - * @param string $source - * @param string $target + * @param string $source + * @param string $target * @return bool + * @throws Exception */ public function move(string $source, string $target): bool { + if($source === $target){ + Throw new Exception('Source and target can not be identical!'); + } + if (! \file_exists(\dirname($target))) { // Checks if directory path to file exists if (! @\mkdir(\dirname($target), 0755, true)) { throw new Exception('Can\'t create directory '.\dirname($target)); diff --git a/tests/Storage/S3Base.php b/tests/Storage/S3Base.php index a06c8aa9..02c0b618 100644 --- a/tests/Storage/S3Base.php +++ b/tests/Storage/S3Base.php @@ -5,6 +5,7 @@ use PHPUnit\Framework\TestCase; use Utopia\Storage\Device\Local; use Utopia\Storage\Device\S3; +use Utopia\Storage\Storage; abstract class S3Base extends TestCase { @@ -114,6 +115,18 @@ public function testMove() $this->object->delete($this->object->getPath('text-for-move-new.txt')); } + public function testMoveIdenticalName() + { + $file = '/kitten-1.jpg'; + + try { + $this->object->move($file, $file); + $this->fail('Failed to throw exception'); + } catch (\Exception $e) { + $this->assertEquals('Source and target can not be identical!', $e->getMessage()); + } + } + public function testDelete() { $this->assertEquals(true, $this->object->write($this->object->getPath('text-for-delete.txt'), 'Hello World', 'text/plain')); diff --git a/tests/Storage/StorageTest.php b/tests/Storage/StorageTest.php index 3f04feb8..df13d3ec 100644 --- a/tests/Storage/StorageTest.php +++ b/tests/Storage/StorageTest.php @@ -39,4 +39,21 @@ public function testExists() $this->assertEquals(Storage::exists('disk-b'), true); $this->assertEquals(Storage::exists('disk-c'), false); } + + /** + * @throws Exception + */ + public function testMoveIdenticalName() + { + $file = '/kitten-1.jpg'; + $device = Storage::getDevice('disk-a'); + + try { + $device->move($file, $file); + $this->fail('Failed to throw exception'); + } catch (\Exception $e) { + $this->assertEquals('Source and target can not be identical!', $e->getMessage()); + } + + } } From afbb668ad2e59a66c101e3fe43b6cd537bbc78db Mon Sep 17 00:00:00 2001 From: fogelito Date: Wed, 23 Aug 2023 10:54:20 +0300 Subject: [PATCH 062/117] xtraline --- tests/Storage/StorageTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Storage/StorageTest.php b/tests/Storage/StorageTest.php index df13d3ec..9258cebe 100644 --- a/tests/Storage/StorageTest.php +++ b/tests/Storage/StorageTest.php @@ -54,6 +54,5 @@ public function testMoveIdenticalName() } catch (\Exception $e) { $this->assertEquals('Source and target can not be identical!', $e->getMessage()); } - } } From 7492e6acedce5eb4d999910f15f0c24ec2bd6ab3 Mon Sep 17 00:00:00 2001 From: fogelito Date: Wed, 23 Aug 2023 10:55:06 +0300 Subject: [PATCH 063/117] lint --- src/Storage/Device.php | 9 +++++---- src/Storage/Device/Local.php | 9 +++++---- tests/Storage/S3Base.php | 1 - 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Storage/Device.php b/src/Storage/Device.php index 2f55f5e7..863928c3 100644 --- a/src/Storage/Device.php +++ b/src/Storage/Device.php @@ -158,15 +158,16 @@ abstract public function write(string $path, string $data, string $contentType): * * @see http://php.net/manual/en/function.filesize.php * - * @param string $source - * @param string $target + * @param string $source + * @param string $target * @return bool + * * @throws Exception */ public function move(string $source, string $target): bool { - if($source === $target){ - Throw new Exception('Source and target can not be identical!'); + if ($source === $target) { + throw new Exception('Source and target can not be identical!'); } if ($this->transfer($source, $target, $this)) { diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index ffff135e..6b5fc795 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -295,15 +295,16 @@ public function write(string $path, string $data, string $contentType = ''): boo * * @see http://php.net/manual/en/function.filesize.php * - * @param string $source - * @param string $target + * @param string $source + * @param string $target * @return bool + * * @throws Exception */ public function move(string $source, string $target): bool { - if($source === $target){ - Throw new Exception('Source and target can not be identical!'); + if ($source === $target) { + throw new Exception('Source and target can not be identical!'); } if (! \file_exists(\dirname($target))) { // Checks if directory path to file exists diff --git a/tests/Storage/S3Base.php b/tests/Storage/S3Base.php index 02c0b618..9bbfd7da 100644 --- a/tests/Storage/S3Base.php +++ b/tests/Storage/S3Base.php @@ -5,7 +5,6 @@ use PHPUnit\Framework\TestCase; use Utopia\Storage\Device\Local; use Utopia\Storage\Device\S3; -use Utopia\Storage\Storage; abstract class S3Base extends TestCase { From 19f2d3f80bf624515be02ba889a63de5b695f655 Mon Sep 17 00:00:00 2001 From: fogelito Date: Sun, 27 Aug 2023 11:05:41 +0300 Subject: [PATCH 064/117] return false --- composer.lock | 16 ++++++++-------- src/Storage/Device.php | 4 +--- src/Storage/Device/Local.php | 2 +- tests/Storage/S3Base.php | 8 +------- tests/Storage/StorageTest.php | 11 +---------- 5 files changed, 12 insertions(+), 29 deletions(-) diff --git a/composer.lock b/composer.lock index 3dafebac..d8cfb9cd 100644 --- a/composer.lock +++ b/composer.lock @@ -653,12 +653,12 @@ "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "40fc8fcd149f6ccff851e767c3fc5ded4e6a96c0" + "reference": "f49f6a836a816609c853718ba2ea422dc18a8e4a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/40fc8fcd149f6ccff851e767c3fc5ded4e6a96c0", - "reference": "40fc8fcd149f6ccff851e767c3fc5ded4e6a96c0", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f49f6a836a816609c853718ba2ea422dc18a8e4a", + "reference": "f49f6a836a816609c853718ba2ea422dc18a8e4a", "shasum": "" }, "require": { @@ -716,7 +716,7 @@ "type": "tidelift" } ], - "time": "2023-07-30T10:00:15+00:00" + "time": "2023-08-24T20:23:35+00:00" }, { "name": "felixfbecker/advanced-json-rpc", @@ -1710,12 +1710,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "6c24b9dd8390a031a5490a2443fff1958522b49a" + "reference": "1e5fec0e7eb197de7e50d5eb5012722dcc38a692" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6c24b9dd8390a031a5490a2443fff1958522b49a", - "reference": "6c24b9dd8390a031a5490a2443fff1958522b49a", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1e5fec0e7eb197de7e50d5eb5012722dcc38a692", + "reference": "1e5fec0e7eb197de7e50d5eb5012722dcc38a692", "shasum": "" }, "require": { @@ -1805,7 +1805,7 @@ "type": "tidelift" } ], - "time": "2023-08-21T05:56:05+00:00" + "time": "2023-08-26T05:31:07+00:00" }, { "name": "psr/container", diff --git a/src/Storage/Device.php b/src/Storage/Device.php index 863928c3..2882b9ff 100644 --- a/src/Storage/Device.php +++ b/src/Storage/Device.php @@ -161,13 +161,11 @@ abstract public function write(string $path, string $data, string $contentType): * @param string $source * @param string $target * @return bool - * - * @throws Exception */ public function move(string $source, string $target): bool { if ($source === $target) { - throw new Exception('Source and target can not be identical!'); + return false; } if ($this->transfer($source, $target, $this)) { diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index 6b5fc795..66cf317b 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -304,7 +304,7 @@ public function write(string $path, string $data, string $contentType = ''): boo public function move(string $source, string $target): bool { if ($source === $target) { - throw new Exception('Source and target can not be identical!'); + return false; } if (! \file_exists(\dirname($target))) { // Checks if directory path to file exists diff --git a/tests/Storage/S3Base.php b/tests/Storage/S3Base.php index 9bbfd7da..70eea4b1 100644 --- a/tests/Storage/S3Base.php +++ b/tests/Storage/S3Base.php @@ -117,13 +117,7 @@ public function testMove() public function testMoveIdenticalName() { $file = '/kitten-1.jpg'; - - try { - $this->object->move($file, $file); - $this->fail('Failed to throw exception'); - } catch (\Exception $e) { - $this->assertEquals('Source and target can not be identical!', $e->getMessage()); - } + $this->assertFalse($this->object->move($file, $file)); } public function testDelete() diff --git a/tests/Storage/StorageTest.php b/tests/Storage/StorageTest.php index 9258cebe..981a4fc2 100644 --- a/tests/Storage/StorageTest.php +++ b/tests/Storage/StorageTest.php @@ -40,19 +40,10 @@ public function testExists() $this->assertEquals(Storage::exists('disk-c'), false); } - /** - * @throws Exception - */ public function testMoveIdenticalName() { $file = '/kitten-1.jpg'; $device = Storage::getDevice('disk-a'); - - try { - $device->move($file, $file); - $this->fail('Failed to throw exception'); - } catch (\Exception $e) { - $this->assertEquals('Source and target can not be identical!', $e->getMessage()); - } + $this->assertFalse($device->move($file, $file)); } } From 03e893fa8615d8266b8e8f93808784761f405114 Mon Sep 17 00:00:00 2001 From: fogelito Date: Mon, 4 Sep 2023 11:30:52 +0300 Subject: [PATCH 065/117] s3 scan dir --- src/Storage/Device/S3.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 625056b5..1c342c8a 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -656,12 +656,13 @@ public function getPartitionTotalSpace(): float /** * Get all files and directories inside a directory. * - * @param string $dir Directory to scan + * @param string $dir Directory to scan * @return string[] + * @throws Exception */ public function getFiles(string $dir): array { - throw new Exception('Not implemented.'); + return $this->listObjects($dir); } /** From 7ecad9daaeb2b1e11d5a281f7a80c91193d5a165 Mon Sep 17 00:00:00 2001 From: fogelito Date: Mon, 4 Sep 2023 14:50:27 +0300 Subject: [PATCH 066/117] s3 scan test --- composer.lock | 108 +++++++++++++++++++------------------- src/Storage/Device.php | 4 +- src/Storage/Device/S3.php | 12 +++-- tests/Storage/S3Base.php | 17 ++++++ 4 files changed, 80 insertions(+), 61 deletions(-) diff --git a/composer.lock b/composer.lock index 54da72ab..4e63d44b 100644 --- a/composer.lock +++ b/composer.lock @@ -74,16 +74,16 @@ }, { "name": "utopia-php/framework", - "version": "0.30.0", + "version": "0.31.0", "source": { "type": "git", "url": "https://github.com/utopia-php/framework.git", - "reference": "0969d429997996ceade53e477fce31221b415651" + "reference": "207f77378965fca9a9bc3783ea379d3549f86bc0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/framework/zipball/0969d429997996ceade53e477fce31221b415651", - "reference": "0969d429997996ceade53e477fce31221b415651", + "url": "https://api.github.com/repos/utopia-php/framework/zipball/207f77378965fca9a9bc3783ea379d3549f86bc0", + "reference": "207f77378965fca9a9bc3783ea379d3549f86bc0", "shasum": "" }, "require": { @@ -113,22 +113,22 @@ ], "support": { "issues": "https://github.com/utopia-php/framework/issues", - "source": "https://github.com/utopia-php/framework/tree/0.30.0" + "source": "https://github.com/utopia-php/framework/tree/0.31.0" }, - "time": "2023-08-07T07:55:48+00:00" + "time": "2023-08-30T16:10:04+00:00" }, { "name": "utopia-php/system", - "version": "0.7.0", + "version": "0.7.1", "source": { "type": "git", "url": "https://github.com/utopia-php/system.git", - "reference": "d385e9521ca3f68aa007ec1cadd11c4dbd871b90" + "reference": "01bf0d283aded0ee0a7a6e5ff540acf64270ab27" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/system/zipball/d385e9521ca3f68aa007ec1cadd11c4dbd871b90", - "reference": "d385e9521ca3f68aa007ec1cadd11c4dbd871b90", + "url": "https://api.github.com/repos/utopia-php/system/zipball/01bf0d283aded0ee0a7a6e5ff540acf64270ab27", + "reference": "01bf0d283aded0ee0a7a6e5ff540acf64270ab27", "shasum": "" }, "require": { @@ -170,9 +170,9 @@ ], "support": { "issues": "https://github.com/utopia-php/system/issues", - "source": "https://github.com/utopia-php/system/tree/0.7.0" + "source": "https://github.com/utopia-php/system/tree/0.7.1" }, - "time": "2023-08-07T09:34:26+00:00" + "time": "2023-08-30T09:14:37+00:00" } ], "packages-dev": [ @@ -422,12 +422,12 @@ "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "fa1ec24f0ab1efe642671ec15c51a3ab879f59bf" + "reference": "1d09200268e7d1052ded8e5da9c73c96a63d18f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/fa1ec24f0ab1efe642671ec15c51a3ab879f59bf", - "reference": "fa1ec24f0ab1efe642671ec15c51a3ab879f59bf", + "url": "https://api.github.com/repos/composer/semver/zipball/1d09200268e7d1052ded8e5da9c73c96a63d18f5", + "reference": "1d09200268e7d1052ded8e5da9c73c96a63d18f5", "shasum": "" }, "require": { @@ -496,7 +496,7 @@ "type": "tidelift" } ], - "time": "2023-01-13T15:47:53+00:00" + "time": "2023-08-31T12:20:31+00:00" }, { "name": "composer/xdebug-handler", @@ -653,12 +653,12 @@ "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "40fc8fcd149f6ccff851e767c3fc5ded4e6a96c0" + "reference": "f49f6a836a816609c853718ba2ea422dc18a8e4a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/40fc8fcd149f6ccff851e767c3fc5ded4e6a96c0", - "reference": "40fc8fcd149f6ccff851e767c3fc5ded4e6a96c0", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f49f6a836a816609c853718ba2ea422dc18a8e4a", + "reference": "f49f6a836a816609c853718ba2ea422dc18a8e4a", "shasum": "" }, "require": { @@ -716,7 +716,7 @@ "type": "tidelift" } ], - "time": "2023-07-30T10:00:15+00:00" + "time": "2023-08-24T20:23:35+00:00" }, { "name": "felixfbecker/advanced-json-rpc", @@ -938,12 +938,12 @@ "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "cfc54e30a4f5e5af5f9d9ce86697cfcc5f7e7c24" + "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/cfc54e30a4f5e5af5f9d9ce86697cfcc5f7e7c24", - "reference": "cfc54e30a4f5e5af5f9d9ce86697cfcc5f7e7c24", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", + "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", "shasum": "" }, "require": { @@ -985,9 +985,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/4.x" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.17.1" }, - "time": "2023-07-30T21:38:32+00:00" + "time": "2023-08-13T19:53:39+00:00" }, { "name": "openlss/lib-array2xml", @@ -1284,12 +1284,12 @@ "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "07100e65d09fd50608d649fc656cae1c921a2495" + "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/07100e65d09fd50608d649fc656cae1c921a2495", - "reference": "07100e65d09fd50608d649fc656cae1c921a2495", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", + "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", "shasum": "" }, "require": { @@ -1333,9 +1333,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.x" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.3" }, - "time": "2023-07-20T19:57:33+00:00" + "time": "2023-08-12T11:01:26+00:00" }, { "name": "phpstan/phpdoc-parser", @@ -1343,12 +1343,12 @@ "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "846ae76eef31c6d7790fac9bc399ecee45160b26" + "reference": "e540adcd37d57d1f46e2b6e172d6140d005226cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/846ae76eef31c6d7790fac9bc399ecee45160b26", - "reference": "846ae76eef31c6d7790fac9bc399ecee45160b26", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/e540adcd37d57d1f46e2b6e172d6140d005226cb", + "reference": "e540adcd37d57d1f46e2b6e172d6140d005226cb", "shasum": "" }, "require": { @@ -1381,9 +1381,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.23.1" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.23.x" }, - "time": "2023-08-03T16:32:59+00:00" + "time": "2023-08-16T11:40:53+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1391,12 +1391,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "9e1baee3a7525530f5600035759ce754a8b3750b" + "reference": "55a161bb93e6a22a21c529515f7ddbb4d489b460" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/9e1baee3a7525530f5600035759ce754a8b3750b", - "reference": "9e1baee3a7525530f5600035759ce754a8b3750b", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/55a161bb93e6a22a21c529515f7ddbb4d489b460", + "reference": "55a161bb93e6a22a21c529515f7ddbb4d489b460", "shasum": "" }, "require": { @@ -1461,7 +1461,7 @@ "type": "github" } ], - "time": "2023-08-02T09:00:29+00:00" + "time": "2023-09-04T05:23:23+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1710,12 +1710,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "6904cfa5f4a6211e759de8ef36fb51fc939a83fa" + "reference": "255265958b65d7c8ac2e301dbdc0a800d8dc7885" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6904cfa5f4a6211e759de8ef36fb51fc939a83fa", - "reference": "6904cfa5f4a6211e759de8ef36fb51fc939a83fa", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/255265958b65d7c8ac2e301dbdc0a800d8dc7885", + "reference": "255265958b65d7c8ac2e301dbdc0a800d8dc7885", "shasum": "" }, "require": { @@ -1805,7 +1805,7 @@ "type": "tidelift" } ], - "time": "2023-08-02T08:56:58+00:00" + "time": "2023-09-04T05:22:44+00:00" }, { "name": "psr/container", @@ -2881,12 +2881,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "b504a3d266ad2bb632f196c0936ef2af5ff6e273" + "reference": "f4f71842f24c2023b91237c72a365306f3c58827" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/b504a3d266ad2bb632f196c0936ef2af5ff6e273", - "reference": "b504a3d266ad2bb632f196c0936ef2af5ff6e273", + "url": "https://api.github.com/repos/symfony/console/zipball/f4f71842f24c2023b91237c72a365306f3c58827", + "reference": "f4f71842f24c2023b91237c72a365306f3c58827", "shasum": "" }, "require": { @@ -2972,7 +2972,7 @@ "type": "tidelift" } ], - "time": "2023-07-19T20:11:33+00:00" + "time": "2023-08-07T06:12:30+00:00" }, { "name": "symfony/deprecation-contracts", @@ -3107,7 +3107,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/1.x" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0" }, "funding": [ { @@ -3189,7 +3189,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/1.x" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.28.0" }, "funding": [ { @@ -3274,7 +3274,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/1.x" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.28.0" }, "funding": [ { @@ -3358,7 +3358,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/1.x" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0" }, "funding": [ { @@ -3438,7 +3438,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/1.x" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.28.0" }, "funding": [ { @@ -3522,7 +3522,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/1.x" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" }, "funding": [ { @@ -4036,5 +4036,5 @@ "php": ">=8.0" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.2.0" } diff --git a/src/Storage/Device.php b/src/Storage/Device.php index fdc73483..79c285fb 100644 --- a/src/Storage/Device.php +++ b/src/Storage/Device.php @@ -270,8 +270,8 @@ abstract public function getPartitionTotalSpace(): float; /** * Get all files and directories inside a directory. * - * @param string $dir Directory to scan - * @return string[] + * @param string $dir Directory to scan + * @return array */ abstract public function getFiles(string $dir): array; diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 1c342c8a..f2262382 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -474,12 +474,14 @@ public function delete(string $path, bool $recursive = false): bool /** * Get list of objects in the given path. * - * @param string $path + * @param string $prefix + * @param int $maxKeys + * @param string $continuationToken * @return array * - * @throws \Exception + * @throws Exception */ - private function listObjects($prefix = '', $maxKeys = 1000, $continuationToken = '') + private function listObjects(string $prefix = '', int $maxKeys = 1000, string $continuationToken = ''): array { $uri = '/'; $prefix = ltrim($prefix, '/'); /** S3 specific requirement that prefix should never contain a leading slash */ @@ -657,12 +659,12 @@ public function getPartitionTotalSpace(): float * Get all files and directories inside a directory. * * @param string $dir Directory to scan - * @return string[] + * @return array * @throws Exception */ public function getFiles(string $dir): array { - return $this->listObjects($dir); + return $this->listObjects($dir, 9999); } /** diff --git a/tests/Storage/S3Base.php b/tests/Storage/S3Base.php index a06c8aa9..729ed7c1 100644 --- a/tests/Storage/S3Base.php +++ b/tests/Storage/S3Base.php @@ -57,6 +57,23 @@ public function tearDown(): void $this->removeTestFiles(); } + public function testGetFiles() + { + $path = $this->object->getPath('testing/'); + $files = $this->object->getFiles($path); + $this->assertEquals('4', $files['KeyCount']); + $this->assertEquals('false', $files['IsTruncated']); + $this->assertIsArray($files['Contents']); + + $file = $files['Contents'][0]; + + $this->assertArrayHasKey('LastModified', $file); + $this->assertArrayHasKey('ETag', $file); + $this->assertArrayHasKey('Size', $file); + $this->assertArrayHasKey('StorageClass', $file); + $this->assertArrayHasKey('Type', $file); + } + public function testName() { $this->assertEquals($this->getAdapterName(), $this->object->getName()); From 43ca43bda0677bce846d1d263f66e8b601b90ce6 Mon Sep 17 00:00:00 2001 From: fogelito Date: Mon, 4 Sep 2023 14:52:12 +0300 Subject: [PATCH 067/117] s3 scan test --- src/Storage/Device.php | 2 +- src/Storage/Device/S3.php | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Storage/Device.php b/src/Storage/Device.php index 79c285fb..74617c9e 100644 --- a/src/Storage/Device.php +++ b/src/Storage/Device.php @@ -270,7 +270,7 @@ abstract public function getPartitionTotalSpace(): float; /** * Get all files and directories inside a directory. * - * @param string $dir Directory to scan + * @param string $dir Directory to scan * @return array */ abstract public function getFiles(string $dir): array; diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index f2262382..3582e514 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -474,9 +474,9 @@ public function delete(string $path, bool $recursive = false): bool /** * Get list of objects in the given path. * - * @param string $prefix - * @param int $maxKeys - * @param string $continuationToken + * @param string $prefix + * @param int $maxKeys + * @param string $continuationToken * @return array * * @throws Exception @@ -658,8 +658,9 @@ public function getPartitionTotalSpace(): float /** * Get all files and directories inside a directory. * - * @param string $dir Directory to scan + * @param string $dir Directory to scan * @return array + * * @throws Exception */ public function getFiles(string $dir): array From 7831cc061f4be65f72444ecf127e1293da1839f7 Mon Sep 17 00:00:00 2001 From: fogelito Date: Mon, 4 Sep 2023 16:29:51 +0300 Subject: [PATCH 068/117] Remove type test --- tests/Storage/S3Base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Storage/S3Base.php b/tests/Storage/S3Base.php index 729ed7c1..1e3ba992 100644 --- a/tests/Storage/S3Base.php +++ b/tests/Storage/S3Base.php @@ -67,11 +67,11 @@ public function testGetFiles() $file = $files['Contents'][0]; + $this->assertArrayHasKey('Key', $file); $this->assertArrayHasKey('LastModified', $file); $this->assertArrayHasKey('ETag', $file); $this->assertArrayHasKey('Size', $file); $this->assertArrayHasKey('StorageClass', $file); - $this->assertArrayHasKey('Type', $file); } public function testName() From 18d00433048a977981115f80f17487fdbbe68884 Mon Sep 17 00:00:00 2001 From: fogelito Date: Mon, 4 Sep 2023 16:37:06 +0300 Subject: [PATCH 069/117] Rerun tests --- tests/Storage/S3Base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Storage/S3Base.php b/tests/Storage/S3Base.php index 1e3ba992..3dbfe3e4 100644 --- a/tests/Storage/S3Base.php +++ b/tests/Storage/S3Base.php @@ -70,8 +70,8 @@ public function testGetFiles() $this->assertArrayHasKey('Key', $file); $this->assertArrayHasKey('LastModified', $file); $this->assertArrayHasKey('ETag', $file); - $this->assertArrayHasKey('Size', $file); $this->assertArrayHasKey('StorageClass', $file); + $this->assertArrayHasKey('Size', $file); } public function testName() From ec38203edf42752cbaaf8ccf0c8762ae0a8033e3 Mon Sep 17 00:00:00 2001 From: fogelito Date: Mon, 4 Sep 2023 17:19:07 +0300 Subject: [PATCH 070/117] Fix types --- src/Storage/Device/S3.php | 5 ++++- tests/Storage/S3Base.php | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 3582e514..0841bc8f 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -665,7 +665,10 @@ public function getPartitionTotalSpace(): float */ public function getFiles(string $dir): array { - return $this->listObjects($dir, 9999); + $data = $this->listObjects($dir); + $data['IsTruncated'] = $data['IsTruncated'] === 'true'; + $data['KeyCount'] = intval($data['KeyCount']); + return $data; } /** diff --git a/tests/Storage/S3Base.php b/tests/Storage/S3Base.php index 3dbfe3e4..b8cd1a8d 100644 --- a/tests/Storage/S3Base.php +++ b/tests/Storage/S3Base.php @@ -61,8 +61,8 @@ public function testGetFiles() { $path = $this->object->getPath('testing/'); $files = $this->object->getFiles($path); - $this->assertEquals('4', $files['KeyCount']); - $this->assertEquals('false', $files['IsTruncated']); + $this->assertEquals(4, $files['KeyCount']); + $this->assertEquals(false, $files['IsTruncated']); $this->assertIsArray($files['Contents']); $file = $files['Contents'][0]; From 76e440f1374bf23bb82f28701786af1a5a3b2d05 Mon Sep 17 00:00:00 2001 From: fogelito Date: Tue, 5 Sep 2023 11:27:10 +0300 Subject: [PATCH 071/117] formatting --- src/Storage/Device/S3.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 0841bc8f..caf50c38 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -668,6 +668,7 @@ public function getFiles(string $dir): array $data = $this->listObjects($dir); $data['IsTruncated'] = $data['IsTruncated'] === 'true'; $data['KeyCount'] = intval($data['KeyCount']); + return $data; } From d116ea2db84cfdd61207e416c17064889bd3a37c Mon Sep 17 00:00:00 2001 From: fogelito Date: Mon, 18 Sep 2023 12:57:11 +0300 Subject: [PATCH 072/117] S3 pagination --- src/Storage/Device.php | 8 +++++--- src/Storage/Device/Local.php | 2 +- src/Storage/Device/S3.php | 19 +++++++++++++++---- tests/Storage/S3Base.php | 19 +++++++++++++++++++ 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/Storage/Device.php b/src/Storage/Device.php index 74617c9e..f71b524b 100644 --- a/src/Storage/Device.php +++ b/src/Storage/Device.php @@ -270,10 +270,12 @@ abstract public function getPartitionTotalSpace(): float; /** * Get all files and directories inside a directory. * - * @param string $dir Directory to scan - * @return array + * @param string $dir Directory to scan + * @param int $keys + * @param string $continuationToken + * @return array */ - abstract public function getFiles(string $dir): array; + abstract public function getFiles(string $dir, int $keys = 1000, string $continuationToken = ''): array; /** * Get the absolute path by resolving strings like ../, .., //, /\ and so on. diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index 6ef23b63..294c3ea7 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -507,7 +507,7 @@ public function getPartitionTotalSpace(): float * @param string $dir Directory to scan * @return string[] */ - public function getFiles(string $dir): array + public function getFiles(string $dir, int $keys = 1000, string $continuationToken = ''): array { if (! (\str_ends_with($dir, DIRECTORY_SEPARATOR))) { $dir .= DIRECTORY_SEPARATOR; diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index caf50c38..1f994862 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -658,24 +658,35 @@ public function getPartitionTotalSpace(): float /** * Get all files and directories inside a directory. * - * @param string $dir Directory to scan - * @return array + * @param string $dir Directory to scan + * @param int $keys + * @param string $continuationToken + * @return array * * @throws Exception */ - public function getFiles(string $dir): array + public function getFiles(string $dir, int $keys = 1000, string $continuationToken = ''): array { - $data = $this->listObjects($dir); + $data = $this->listObjects($dir, $keys, $continuationToken); + + // Set to false if all the results were returned. Set to true if more keys are available to return. $data['IsTruncated'] = $data['IsTruncated'] === 'true'; + + // KeyCount is the number of keys returned with this request. $data['KeyCount'] = intval($data['KeyCount']); + // Sets the maximum number of keys returned to the response. By default, the action returns up to 1,000 key names. + $data['MaxKeys'] = intval($data['MaxKeys']); + return $data; } /** * Get file info * + * @param string $path * @return array + * @throws Exception */ private function getInfo(string $path): array { diff --git a/tests/Storage/S3Base.php b/tests/Storage/S3Base.php index b8cd1a8d..3857eca8 100644 --- a/tests/Storage/S3Base.php +++ b/tests/Storage/S3Base.php @@ -74,6 +74,25 @@ public function testGetFiles() $this->assertArrayHasKey('Size', $file); } + public function testGetFilesPagination() + { + $path = $this->object->getPath('testing/'); + + $files = $this->object->getFiles($path, 3); + $this->assertEquals(3, $files['KeyCount']); + $this->assertEquals(1000, $files['MaxKeys']); + $this->assertEquals(true, $files['IsTruncated']); + $this->assertIsArray($files['Contents']); + $this->assertNotEmpty($files['NextContinuationToken']); + + $files = $this->object->getFiles($path, 3, $files['NextContinuationToken']); + $this->assertEquals(1, $files['KeyCount']); + $this->assertEquals(1000, $files['MaxKeys']); + $this->assertEquals(false, $files['IsTruncated']); + $this->assertIsArray($files['Contents']); + $this->assertEmpty($files['NextContinuationToken']); + } + public function testName() { $this->assertEquals($this->getAdapterName(), $this->object->getName()); From abdb8f4e9ee831c1d50aba5730dd1bbebf60794a Mon Sep 17 00:00:00 2001 From: fogelito Date: Mon, 18 Sep 2023 14:37:02 +0300 Subject: [PATCH 073/117] max keys --- tests/Storage/S3Base.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Storage/S3Base.php b/tests/Storage/S3Base.php index 3857eca8..4e3531b3 100644 --- a/tests/Storage/S3Base.php +++ b/tests/Storage/S3Base.php @@ -80,12 +80,12 @@ public function testGetFilesPagination() $files = $this->object->getFiles($path, 3); $this->assertEquals(3, $files['KeyCount']); - $this->assertEquals(1000, $files['MaxKeys']); + $this->assertEquals(3, $files['MaxKeys']); $this->assertEquals(true, $files['IsTruncated']); $this->assertIsArray($files['Contents']); $this->assertNotEmpty($files['NextContinuationToken']); - $files = $this->object->getFiles($path, 3, $files['NextContinuationToken']); + $files = $this->object->getFiles($path, 1000, $files['NextContinuationToken']); $this->assertEquals(1, $files['KeyCount']); $this->assertEquals(1000, $files['MaxKeys']); $this->assertEquals(false, $files['IsTruncated']); From d4a6d4658fb37871d1bc2d645e9ec139cbad5dbb Mon Sep 17 00:00:00 2001 From: fogelito Date: Mon, 18 Sep 2023 14:59:00 +0300 Subject: [PATCH 074/117] NextContinuationToken --- src/Storage/Device/S3.php | 4 +++- tests/Storage/S3Base.php | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 1f994862..26522ef8 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -493,9 +493,11 @@ private function listObjects(string $prefix = '', int $maxKeys = 1000, string $c 'prefix' => $prefix, 'max-keys' => $maxKeys, ]; - if (! empty($continuationToken)) { + + if (!empty($continuationToken)) { $parameters['continuation-token'] = $continuationToken; } + $response = $this->call(self::METHOD_GET, $uri, '', $parameters); return $response->body; diff --git a/tests/Storage/S3Base.php b/tests/Storage/S3Base.php index 4e3531b3..b9228712 100644 --- a/tests/Storage/S3Base.php +++ b/tests/Storage/S3Base.php @@ -83,14 +83,14 @@ public function testGetFilesPagination() $this->assertEquals(3, $files['MaxKeys']); $this->assertEquals(true, $files['IsTruncated']); $this->assertIsArray($files['Contents']); - $this->assertNotEmpty($files['NextContinuationToken']); + $this->assertArrayHasKey('NextContinuationToken', $files); $files = $this->object->getFiles($path, 1000, $files['NextContinuationToken']); $this->assertEquals(1, $files['KeyCount']); $this->assertEquals(1000, $files['MaxKeys']); $this->assertEquals(false, $files['IsTruncated']); $this->assertIsArray($files['Contents']); - $this->assertEmpty($files['NextContinuationToken']); + $this->assertArrayNotHasKey('NextContinuationToken', $files); } public function testName() From c9e972ea76d6cb584eea761852197ae926183824 Mon Sep 17 00:00:00 2001 From: fogelito Date: Mon, 18 Sep 2023 16:51:23 +0300 Subject: [PATCH 075/117] $maxKeys limit --- src/Storage/Device/S3.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 26522ef8..e70b2dc1 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -483,6 +483,10 @@ public function delete(string $path, bool $recursive = false): bool */ private function listObjects(string $prefix = '', int $maxKeys = 1000, string $continuationToken = ''): array { + if($maxKeys > 1000){ + throw new Exception('max-keys limit is 1000'); + } + $uri = '/'; $prefix = ltrim($prefix, '/'); /** S3 specific requirement that prefix should never contain a leading slash */ $this->headers['content-type'] = 'text/plain'; From a4a19b9610ac4bfe634abd4b707b7cd2987cd7fe Mon Sep 17 00:00:00 2001 From: fogelito Date: Mon, 18 Sep 2023 17:38:25 +0300 Subject: [PATCH 076/117] Const MAX_KEYS --- src/Storage/Device.php | 9 +++++++-- src/Storage/Device/Local.php | 2 +- src/Storage/Device/S3.php | 6 +++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Storage/Device.php b/src/Storage/Device.php index f71b524b..2ba7b7c0 100644 --- a/src/Storage/Device.php +++ b/src/Storage/Device.php @@ -5,10 +5,15 @@ abstract class Device { /** - * Max chunk size while transfering file from one device to another + * Max chunk size while transferring file from one device to another */ protected int $transferChunkSize = 20000000; //20 MB + /** + * Sets the maximum number of keys returned to the response. By default, the action returns up to 1,000 key names. + */ + protected const MAX_KEYS = 1000; + /** * Set Transfer Chunk Size * @@ -275,7 +280,7 @@ abstract public function getPartitionTotalSpace(): float; * @param string $continuationToken * @return array */ - abstract public function getFiles(string $dir, int $keys = 1000, string $continuationToken = ''): array; + abstract public function getFiles(string $dir, int $keys = self::MAX_KEYS, string $continuationToken = ''): array; /** * Get the absolute path by resolving strings like ../, .., //, /\ and so on. diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index 294c3ea7..15a31b69 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -507,7 +507,7 @@ public function getPartitionTotalSpace(): float * @param string $dir Directory to scan * @return string[] */ - public function getFiles(string $dir, int $keys = 1000, string $continuationToken = ''): array + public function getFiles(string $dir, int $keys = self::MAX_KEYS, string $continuationToken = ''): array { if (! (\str_ends_with($dir, DIRECTORY_SEPARATOR))) { $dir .= DIRECTORY_SEPARATOR; diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index e70b2dc1..bf5da800 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -481,9 +481,9 @@ public function delete(string $path, bool $recursive = false): bool * * @throws Exception */ - private function listObjects(string $prefix = '', int $maxKeys = 1000, string $continuationToken = ''): array + private function listObjects(string $prefix = '', int $maxKeys = self::MAX_KEYS, string $continuationToken = ''): array { - if($maxKeys > 1000){ + if($maxKeys > self::MAX_KEYS){ throw new Exception('max-keys limit is 1000'); } @@ -671,7 +671,7 @@ public function getPartitionTotalSpace(): float * * @throws Exception */ - public function getFiles(string $dir, int $keys = 1000, string $continuationToken = ''): array + public function getFiles(string $dir, int $keys = self::MAX_KEYS, string $continuationToken = ''): array { $data = $this->listObjects($dir, $keys, $continuationToken); From f7a7b6e6f1cd21c68b83d3096380d5af9aa944eb Mon Sep 17 00:00:00 2001 From: fogelito Date: Mon, 18 Sep 2023 17:39:36 +0300 Subject: [PATCH 077/117] Const MAX_KEYS --- src/Storage/Device/S3.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index bf5da800..79bc2835 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -484,7 +484,7 @@ public function delete(string $path, bool $recursive = false): bool private function listObjects(string $prefix = '', int $maxKeys = self::MAX_KEYS, string $continuationToken = ''): array { if($maxKeys > self::MAX_KEYS){ - throw new Exception('max-keys limit is 1000'); + throw new Exception('max-keys limit is ' . self::MAX_KEYS); } $uri = '/'; From 397afbb79dce7decc952bbfe7686bf6858d3babd Mon Sep 17 00:00:00 2001 From: fogelito Date: Tue, 19 Sep 2023 16:23:30 +0300 Subject: [PATCH 078/117] Const MAX_KEYS --- src/Storage/Device.php | 6 +++--- src/Storage/Device/S3.php | 15 ++++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Storage/Device.php b/src/Storage/Device.php index 2ba7b7c0..ea7915ad 100644 --- a/src/Storage/Device.php +++ b/src/Storage/Device.php @@ -275,9 +275,9 @@ abstract public function getPartitionTotalSpace(): float; /** * Get all files and directories inside a directory. * - * @param string $dir Directory to scan - * @param int $keys - * @param string $continuationToken + * @param string $dir Directory to scan + * @param int $keys + * @param string $continuationToken * @return array */ abstract public function getFiles(string $dir, int $keys = self::MAX_KEYS, string $continuationToken = ''): array; diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 79bc2835..d46bdbd5 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -483,8 +483,8 @@ public function delete(string $path, bool $recursive = false): bool */ private function listObjects(string $prefix = '', int $maxKeys = self::MAX_KEYS, string $continuationToken = ''): array { - if($maxKeys > self::MAX_KEYS){ - throw new Exception('max-keys limit is ' . self::MAX_KEYS); + if ($maxKeys > self::MAX_KEYS) { + throw new Exception('max-keys limit is '.self::MAX_KEYS); } $uri = '/'; @@ -498,7 +498,7 @@ private function listObjects(string $prefix = '', int $maxKeys = self::MAX_KEYS, 'max-keys' => $maxKeys, ]; - if (!empty($continuationToken)) { + if (! empty($continuationToken)) { $parameters['continuation-token'] = $continuationToken; } @@ -664,9 +664,9 @@ public function getPartitionTotalSpace(): float /** * Get all files and directories inside a directory. * - * @param string $dir Directory to scan - * @param int $keys - * @param string $continuationToken + * @param string $dir Directory to scan + * @param int $keys + * @param string $continuationToken * @return array * * @throws Exception @@ -690,8 +690,9 @@ public function getFiles(string $dir, int $keys = self::MAX_KEYS, string $contin /** * Get file info * - * @param string $path + * @param string $path * @return array + * * @throws Exception */ private function getInfo(string $path): array From aa7060a474f7363b61b72562a8dc68fedffdb816 Mon Sep 17 00:00:00 2001 From: Shmuel Fogel Date: Thu, 12 Oct 2023 12:05:38 +0300 Subject: [PATCH 079/117] Update src/Storage/Device/S3.php Co-authored-by: Jake Barnby --- src/Storage/Device/S3.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index d46bdbd5..f2243bed 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -484,7 +484,7 @@ public function delete(string $path, bool $recursive = false): bool private function listObjects(string $prefix = '', int $maxKeys = self::MAX_KEYS, string $continuationToken = ''): array { if ($maxKeys > self::MAX_KEYS) { - throw new Exception('max-keys limit is '.self::MAX_KEYS); + throw new Exception('Cannot list more than ' . self::MAX_KEYS . ' objects'); } $uri = '/'; From 0bd69e11152029e1a3bdb83264d174304d78fde7 Mon Sep 17 00:00:00 2001 From: fogelito Date: Thu, 12 Oct 2023 12:14:45 +0300 Subject: [PATCH 080/117] Address comments --- composer.lock | 70 ++++++++++++++++++------------------ src/Storage/Device.php | 6 ++-- src/Storage/Device/Local.php | 10 +++--- src/Storage/Device/S3.php | 14 ++++---- 4 files changed, 50 insertions(+), 50 deletions(-) diff --git a/composer.lock b/composer.lock index 4e63d44b..e597babb 100644 --- a/composer.lock +++ b/composer.lock @@ -605,12 +605,12 @@ "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "bdaa697ed9c7f5ee2f7d3b5f9c2a6f2519523cd9" + "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/bdaa697ed9c7f5ee2f7d3b5f9c2a6f2519523cd9", - "reference": "bdaa697ed9c7f5ee2f7d3b5f9c2a6f2519523cd9", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/4f2d4f2836e7ec4e7a8625e75c6aa916004db931", + "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931", "shasum": "" }, "require": { @@ -643,9 +643,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/1.1.x" + "source": "https://github.com/doctrine/deprecations/tree/1.1.2" }, - "time": "2023-07-29T16:12:19+00:00" + "time": "2023-09-27T20:04:15+00:00" }, { "name": "doctrine/instantiator", @@ -938,12 +938,12 @@ "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d" + "reference": "54103d838734be0499172026525e38cbf6af2711" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", - "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/54103d838734be0499172026525e38cbf6af2711", + "reference": "54103d838734be0499172026525e38cbf6af2711", "shasum": "" }, "require": { @@ -954,7 +954,6 @@ "ircmaxell/php-yacc": "^0.0.7", "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" }, - "default-branch": true, "bin": [ "bin/php-parse" ], @@ -985,9 +984,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.17.1" + "source": "https://github.com/nikic/PHP-Parser/tree/4.x" }, - "time": "2023-08-13T19:53:39+00:00" + "time": "2023-10-03T21:00:18+00:00" }, { "name": "openlss/lib-array2xml", @@ -1339,16 +1338,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.23.x-dev", + "version": "1.24.2", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "e540adcd37d57d1f46e2b6e172d6140d005226cb" + "reference": "bcad8d995980440892759db0c32acae7c8e79442" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/e540adcd37d57d1f46e2b6e172d6140d005226cb", - "reference": "e540adcd37d57d1f46e2b6e172d6140d005226cb", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bcad8d995980440892759db0c32acae7c8e79442", + "reference": "bcad8d995980440892759db0c32acae7c8e79442", "shasum": "" }, "require": { @@ -1365,7 +1364,6 @@ "phpunit/phpunit": "^9.5", "symfony/process": "^5.2" }, - "default-branch": true, "type": "library", "autoload": { "psr-4": { @@ -1381,9 +1379,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.23.x" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.2" }, - "time": "2023-08-16T11:40:53+00:00" + "time": "2023-09-26T12:28:12+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1391,12 +1389,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "55a161bb93e6a22a21c529515f7ddbb4d489b460" + "reference": "0b6cb84a359426d34e439ce6d1173b41e07cb672" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/55a161bb93e6a22a21c529515f7ddbb4d489b460", - "reference": "55a161bb93e6a22a21c529515f7ddbb4d489b460", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/0b6cb84a359426d34e439ce6d1173b41e07cb672", + "reference": "0b6cb84a359426d34e439ce6d1173b41e07cb672", "shasum": "" }, "require": { @@ -1461,7 +1459,7 @@ "type": "github" } ], - "time": "2023-09-04T05:23:23+00:00" + "time": "2023-10-06T09:53:04+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1710,12 +1708,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "255265958b65d7c8ac2e301dbdc0a800d8dc7885" + "reference": "18a76cf7293527f275342720eeb063dff346c97e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/255265958b65d7c8ac2e301dbdc0a800d8dc7885", - "reference": "255265958b65d7c8ac2e301dbdc0a800d8dc7885", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/18a76cf7293527f275342720eeb063dff346c97e", + "reference": "18a76cf7293527f275342720eeb063dff346c97e", "shasum": "" }, "require": { @@ -1730,7 +1728,7 @@ "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.13", + "phpunit/php-code-coverage": "^9.2.28", "phpunit/php-file-iterator": "^3.0.5", "phpunit/php-invoker": "^3.1.1", "phpunit/php-text-template": "^2.0.3", @@ -1805,7 +1803,7 @@ "type": "tidelift" } ], - "time": "2023-09-04T05:22:44+00:00" + "time": "2023-10-06T09:52:37+00:00" }, { "name": "psr/container", @@ -1813,12 +1811,12 @@ "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "90db7b9ac2a2c5b849fcb69dde58f3ae182c68f5" + "reference": "707984727bd5b2b670e59559d3ed2500240cf875" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/90db7b9ac2a2c5b849fcb69dde58f3ae182c68f5", - "reference": "90db7b9ac2a2c5b849fcb69dde58f3ae182c68f5", + "url": "https://api.github.com/repos/php-fig/container/zipball/707984727bd5b2b670e59559d3ed2500240cf875", + "reference": "707984727bd5b2b670e59559d3ed2500240cf875", "shasum": "" }, "require": { @@ -1857,9 +1855,9 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/master" + "source": "https://github.com/php-fig/container" }, - "time": "2022-07-19T17:36:59+00:00" + "time": "2023-09-22T11:11:30+00:00" }, { "name": "psr/log", @@ -3629,12 +3627,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "fe9228ba417441e16f31d36ddad2b3076135f453" + "reference": "742351f7542c9b9799873e399a716cb5af6f70f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/fe9228ba417441e16f31d36ddad2b3076135f453", - "reference": "fe9228ba417441e16f31d36ddad2b3076135f453", + "url": "https://api.github.com/repos/symfony/string/zipball/742351f7542c9b9799873e399a716cb5af6f70f2", + "reference": "742351f7542c9b9799873e399a716cb5af6f70f2", "shasum": "" }, "require": { @@ -3707,7 +3705,7 @@ "type": "tidelift" } ], - "time": "2023-07-27T06:52:43+00:00" + "time": "2023-09-18T10:40:25+00:00" }, { "name": "theseer/tokenizer", diff --git a/src/Storage/Device.php b/src/Storage/Device.php index ea7915ad..8f3207fc 100644 --- a/src/Storage/Device.php +++ b/src/Storage/Device.php @@ -12,7 +12,7 @@ abstract class Device /** * Sets the maximum number of keys returned to the response. By default, the action returns up to 1,000 key names. */ - protected const MAX_KEYS = 1000; + protected const MAX_PAGE_SIZE = PHP_INT_MAX; /** * Set Transfer Chunk Size @@ -276,11 +276,11 @@ abstract public function getPartitionTotalSpace(): float; * Get all files and directories inside a directory. * * @param string $dir Directory to scan - * @param int $keys + * @param int $max * @param string $continuationToken * @return array */ - abstract public function getFiles(string $dir, int $keys = self::MAX_KEYS, string $continuationToken = ''): array; + abstract public function getFiles(string $dir, int $max = self::MAX_PAGE_SIZE, string $continuationToken = ''): array; /** * Get the absolute path by resolving strings like ../, .., //, /\ and so on. diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index 15a31b69..1d1570ce 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -501,13 +501,13 @@ public function getPartitionTotalSpace(): float return \disk_total_space($this->getRoot()); } - /** - * Get all files and directories inside a directory. - * - * @param string $dir Directory to scan + /**s + * @param string $dir + * @param int $max + * @param string $continuationToken * @return string[] */ - public function getFiles(string $dir, int $keys = self::MAX_KEYS, string $continuationToken = ''): array + public function getFiles(string $dir, int $max = self::MAX_PAGE_SIZE, string $continuationToken = ''): array { if (! (\str_ends_with($dir, DIRECTORY_SEPARATOR))) { $dir .= DIRECTORY_SEPARATOR; diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index f2243bed..79aadeff 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -92,6 +92,8 @@ class S3 extends Device const ACL_AUTHENTICATED_READ = 'authenticated-read'; + protected const MAX_PAGE_SIZE = 1000; + /** * @var string */ @@ -481,10 +483,10 @@ public function delete(string $path, bool $recursive = false): bool * * @throws Exception */ - private function listObjects(string $prefix = '', int $maxKeys = self::MAX_KEYS, string $continuationToken = ''): array + private function listObjects(string $prefix = '', int $maxKeys = self::MAX_PAGE_SIZE, string $continuationToken = ''): array { - if ($maxKeys > self::MAX_KEYS) { - throw new Exception('Cannot list more than ' . self::MAX_KEYS . ' objects'); + if ($maxKeys > self::MAX_PAGE_SIZE) { + throw new Exception('Cannot list more than '.self::MAX_PAGE_SIZE.' objects'); } $uri = '/'; @@ -665,15 +667,15 @@ public function getPartitionTotalSpace(): float * Get all files and directories inside a directory. * * @param string $dir Directory to scan - * @param int $keys + * @param int $max * @param string $continuationToken * @return array * * @throws Exception */ - public function getFiles(string $dir, int $keys = self::MAX_KEYS, string $continuationToken = ''): array + public function getFiles(string $dir, int $max = self::MAX_PAGE_SIZE, string $continuationToken = ''): array { - $data = $this->listObjects($dir, $keys, $continuationToken); + $data = $this->listObjects($dir, $max, $continuationToken); // Set to false if all the results were returned. Set to true if more keys are available to return. $data['IsTruncated'] = $data['IsTruncated'] === 'true'; From cf00a56b278ffc2f36944419dbe96f24a5bf9686 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 18 Oct 2023 21:17:36 +1300 Subject: [PATCH 081/117] Update src/Storage/Device/Local.php --- src/Storage/Device/Local.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index 1d1570ce..c39f553f 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -501,7 +501,9 @@ public function getPartitionTotalSpace(): float return \disk_total_space($this->getRoot()); } - /**s + /** + * Get all files and directories inside a directory. + * * @param string $dir * @param int $max * @param string $continuationToken From 39a8f7b6670e46052a1a6328bdc7483b3baf7fa5 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 18 Oct 2023 21:23:18 +1300 Subject: [PATCH 082/117] Fix format --- src/Storage/Device/Local.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index 372f1bcf..65149917 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -510,9 +510,9 @@ public function getPartitionTotalSpace(): float /** * Get all files and directories inside a directory. * - * @param string $dir - * @param int $max - * @param string $continuationToken + * @param string $dir + * @param int $max + * @param string $continuationToken * @return string[] */ public function getFiles(string $dir, int $max = self::MAX_PAGE_SIZE, string $continuationToken = ''): array From 5145685d41b359cd2447164b671b198ff8b307af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 24 Oct 2023 14:17:45 +0000 Subject: [PATCH 083/117] Fix symlink deletion --- src/Storage/Device/Local.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index 65149917..13bed91a 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -339,7 +339,7 @@ public function delete(string $path, bool $recursive = false): bool } \rmdir($path); - } elseif (\is_file($path)) { + } elseif (\is_file($path) || \is_link($path)) { return \unlink($path); } From 5af2bd060e8f3280c6b31f597848b615981519f2 Mon Sep 17 00:00:00 2001 From: Marton Schneider Date: Sat, 18 Nov 2023 13:13:38 +0100 Subject: [PATCH 084/117] optionally can define endpoint URL --- src/Storage/Device/S3.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 79aadeff..0c25762f 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -148,7 +148,7 @@ class S3 extends Device * @param string $region * @param string $acl */ - public function __construct(string $root, string $accessKey, string $secretKey, string $bucket, string $region = self::US_EAST_1, string $acl = self::ACL_PRIVATE) + public function __construct(string $root, string $accessKey, string $secretKey, string $bucket, string $region = self::US_EAST_1, string $acl = self::ACL_PRIVATE, $endpointUrl = '') { $this->accessKey = $accessKey; $this->secretKey = $secretKey; @@ -158,10 +158,14 @@ public function __construct(string $root, string $accessKey, string $secretKey, $this->acl = $acl; $this->amzHeaders = []; - $host = match ($region) { - self::CN_NORTH_1, self::CN_NORTH_4, self::CN_NORTHWEST_1 => $bucket.'.s3.'.$region.'.amazonaws.cn', - default => $bucket.'.s3.'.$region.'.amazonaws.com' - }; + if (!empty($endpointUrl)) { + $host = $bucket.'.'.$endpointUrl; + } else { + $host = match ($region) { + self::CN_NORTH_1, self::CN_NORTH_4, self::CN_NORTHWEST_1 => $bucket.'.s3.'.$region.'.amazonaws.cn', + default => $bucket.'.s3.'.$region.'.amazonaws.com' + }; + } $this->headers['host'] = $host; } From 73f63443cfed5d9d5fe79c5ab0793220347399a4 Mon Sep 17 00:00:00 2001 From: Marton Schneider Date: Thu, 23 Nov 2023 18:49:39 +0100 Subject: [PATCH 085/117] fix lint errors --- src/Storage/Device/S3.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 0c25762f..f3b5c451 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -128,7 +128,8 @@ class S3 extends Device * @var array */ protected array $headers = [ - 'host' => '', 'date' => '', + 'host' => '', + 'date' => '', 'content-md5' => '', 'content-type' => '', ]; @@ -158,12 +159,12 @@ public function __construct(string $root, string $accessKey, string $secretKey, $this->acl = $acl; $this->amzHeaders = []; - if (!empty($endpointUrl)) { + if (! empty($endpointUrl)) { $host = $bucket.'.'.$endpointUrl; } else { $host = match ($region) { - self::CN_NORTH_1, self::CN_NORTH_4, self::CN_NORTHWEST_1 => $bucket.'.s3.'.$region.'.amazonaws.cn', - default => $bucket.'.s3.'.$region.'.amazonaws.com' + self::CN_NORTH_1, self::CN_NORTH_4, self::CN_NORTHWEST_1 => $bucket.'.s3.'.$region.'.amazonaws.cn', + default => $bucket.'.s3.'.$region.'.amazonaws.com' }; } @@ -769,8 +770,10 @@ private function getSignatureV4(string $method, string $uri, array $parameters = // stringToSign $stringToSignStr = \implode("\n", [ - $algorithm, $this->amzHeaders['x-amz-date'], - \implode('/', $credentialScope), \hash('sha256', $amzPayloadStr), + $algorithm, + $this->amzHeaders['x-amz-date'], + \implode('/', $credentialScope), + \hash('sha256', $amzPayloadStr), ]); // Make Signature From a681fb338be2e12c3cfdf5719298f40daa078186 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 31 Dec 2023 11:19:04 +0000 Subject: [PATCH 086/117] static compression types --- src/Storage/Compression/Compression.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Storage/Compression/Compression.php b/src/Storage/Compression/Compression.php index 8eda71f4..3fe60fe3 100644 --- a/src/Storage/Compression/Compression.php +++ b/src/Storage/Compression/Compression.php @@ -4,6 +4,13 @@ abstract class Compression { + public const ZSTD = 'zstd'; + public const GZIP = 'gzip'; + public const BROTLI = 'brotli'; + public const LZ4 = 'lz4'; + public const SNAPPY = 'snappy'; + public const XZ = 'xz'; + /** * Return the name of compression algorithm. * From 9c5de48b6b48bc7ce79b0367d285c10cb62ef275 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 31 Dec 2023 11:23:45 +0000 Subject: [PATCH 087/117] fix formatting --- src/Storage/Compression/Compression.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Storage/Compression/Compression.php b/src/Storage/Compression/Compression.php index 3fe60fe3..bb605d73 100644 --- a/src/Storage/Compression/Compression.php +++ b/src/Storage/Compression/Compression.php @@ -5,10 +5,15 @@ abstract class Compression { public const ZSTD = 'zstd'; + public const GZIP = 'gzip'; + public const BROTLI = 'brotli'; + public const LZ4 = 'lz4'; + public const SNAPPY = 'snappy'; + public const XZ = 'xz'; /** From fc98c944be3c22038c6fa5b938dc9167d56ba7e1 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 31 Dec 2023 17:27:54 +0545 Subject: [PATCH 088/117] Update Compression.php --- src/Storage/Compression/Compression.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Storage/Compression/Compression.php b/src/Storage/Compression/Compression.php index bb605d73..57b57d90 100644 --- a/src/Storage/Compression/Compression.php +++ b/src/Storage/Compression/Compression.php @@ -16,6 +16,8 @@ abstract class Compression public const XZ = 'xz'; + public const NONE = 'none'; + /** * Return the name of compression algorithm. * From 9df598b91a0eb0a5900752a59d929ace584a591b Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 22 Jan 2024 07:42:29 +0000 Subject: [PATCH 089/117] update list objects to reset headers --- src/Storage/Device/S3.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index f3b5c451..927e6719 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -496,6 +496,8 @@ private function listObjects(string $prefix = '', int $maxKeys = self::MAX_PAGE_ $uri = '/'; $prefix = ltrim($prefix, '/'); /** S3 specific requirement that prefix should never contain a leading slash */ + unset($this->amzHeaders['x-amz-acl']); + unset($this->amzHeaders['x-amz-content-sha256']); $this->headers['content-type'] = 'text/plain'; $this->headers['content-md5'] = \base64_encode(md5('', true)); From 80eafa63cb86b33ce35d48c0189bae6ebdc02734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Fri, 8 Mar 2024 09:39:46 +0000 Subject: [PATCH 090/117] Fix validators --- composer.json | 2 +- composer.lock | 501 ++++++++++++++--------------- src/Storage/Validator/File.php | 2 +- src/Storage/Validator/FileExt.php | 2 +- src/Storage/Validator/FileName.php | 2 +- src/Storage/Validator/FileSize.php | 2 +- src/Storage/Validator/FileType.php | 2 +- src/Storage/Validator/Upload.php | 2 +- 8 files changed, 249 insertions(+), 266 deletions(-) diff --git a/composer.json b/composer.json index 3dde33f0..080f1557 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "ext-lz4": "*", "ext-snappy": "*", "php": ">=8.0", - "utopia-php/framework": "0.*.*", + "utopia-php/framework": "0.34.*", "utopia-php/system": "0.*.*" }, "require-dev": { diff --git a/composer.lock b/composer.lock index e597babb..0a0fb5c2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,141 +4,77 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "024174312546d59cde20dd0dd4e6186d", + "content-hash": "a2a5687c81b47dd5385eb0db14b6bb06", "packages": [ - { - "name": "laravel/pint", - "version": "v1.2.1", - "source": { - "type": "git", - "url": "https://github.com/laravel/pint.git", - "reference": "e60e2112ee779ce60f253695b273d1646a17d6f1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/e60e2112ee779ce60f253695b273d1646a17d6f1", - "reference": "e60e2112ee779ce60f253695b273d1646a17d6f1", - "shasum": "" - }, - "require": { - "ext-json": "*", - "ext-mbstring": "*", - "ext-tokenizer": "*", - "ext-xml": "*", - "php": "^8.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^3.11.0", - "illuminate/view": "^9.32.0", - "laravel-zero/framework": "^9.2.0", - "mockery/mockery": "^1.5.1", - "nunomaduro/larastan": "^2.2.0", - "nunomaduro/termwind": "^1.14.0", - "pestphp/pest": "^1.22.1" - }, - "bin": [ - "builds/pint" - ], - "type": "project", - "autoload": { - "psr-4": { - "App\\": "app/", - "Database\\Seeders\\": "database/seeders/", - "Database\\Factories\\": "database/factories/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nuno Maduro", - "email": "enunomaduro@gmail.com" - } - ], - "description": "An opinionated code formatter for PHP.", - "homepage": "https://laravel.com", - "keywords": [ - "format", - "formatter", - "lint", - "linter", - "php" - ], - "support": { - "issues": "https://github.com/laravel/pint/issues", - "source": "https://github.com/laravel/pint" - }, - "time": "2022-11-29T16:25:20+00:00" - }, { "name": "utopia-php/framework", - "version": "0.31.0", + "version": "0.34.2", "source": { "type": "git", - "url": "https://github.com/utopia-php/framework.git", - "reference": "207f77378965fca9a9bc3783ea379d3549f86bc0" + "url": "https://github.com/utopia-php/http.git", + "reference": "fd126c02b78cc80678c9638f7b335dfb4a841b78" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/framework/zipball/207f77378965fca9a9bc3783ea379d3549f86bc0", - "reference": "207f77378965fca9a9bc3783ea379d3549f86bc0", + "url": "https://api.github.com/repos/utopia-php/http/zipball/fd126c02b78cc80678c9638f7b335dfb4a841b78", + "reference": "fd126c02b78cc80678c9638f7b335dfb4a841b78", "shasum": "" }, "require": { + "ext-swoole": "*", "php": ">=8.0" }, "require-dev": { "laravel/pint": "^1.2", "phpbench/phpbench": "^1.2", "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^9.5.25" + "phpunit/phpunit": "^9.5.25", + "swoole/ide-helper": "4.8.3" }, "type": "library", "autoload": { "psr-4": { - "Utopia\\": "src/" + "Utopia\\Http\\": "src/Http" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "description": "A simple, light and advanced PHP framework", + "description": "A simple, light and advanced PHP HTTP framework", "keywords": [ "framework", + "http", "php", "upf" ], "support": { - "issues": "https://github.com/utopia-php/framework/issues", - "source": "https://github.com/utopia-php/framework/tree/0.31.0" + "issues": "https://github.com/utopia-php/http/issues", + "source": "https://github.com/utopia-php/http/tree/0.34.2" }, - "time": "2023-08-30T16:10:04+00:00" + "time": "2024-02-20T11:36:56+00:00" }, { "name": "utopia-php/system", - "version": "0.7.1", + "version": "0.7.2", "source": { "type": "git", "url": "https://github.com/utopia-php/system.git", - "reference": "01bf0d283aded0ee0a7a6e5ff540acf64270ab27" + "reference": "4593d4d334b0c15879c4744a826e0362924c5d66" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/system/zipball/01bf0d283aded0ee0a7a6e5ff540acf64270ab27", - "reference": "01bf0d283aded0ee0a7a6e5ff540acf64270ab27", + "url": "https://api.github.com/repos/utopia-php/system/zipball/4593d4d334b0c15879c4744a826e0362924c5d66", + "reference": "4593d4d334b0c15879c4744a826e0362924c5d66", "shasum": "" }, "require": { - "laravel/pint": "1.2.*", "php": ">=8.0.0" }, "require-dev": { - "phpunit/phpunit": "^9.3", - "squizlabs/php_codesniffer": "^3.6", - "vimeo/psalm": "4.0.1" + "laravel/pint": "1.13.*", + "phpstan/phpstan": "1.10.*", + "phpunit/phpunit": "9.6.*" }, "type": "library", "autoload": { @@ -170,9 +106,9 @@ ], "support": { "issues": "https://github.com/utopia-php/system/issues", - "source": "https://github.com/utopia-php/system/tree/0.7.1" + "source": "https://github.com/utopia-php/system/tree/0.7.2" }, - "time": "2023-08-30T09:14:37+00:00" + "time": "2023-10-20T01:39:17+00:00" } ], "packages-dev": [ @@ -605,12 +541,12 @@ "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931" + "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/4f2d4f2836e7ec4e7a8625e75c6aa916004db931", - "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", + "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", "shasum": "" }, "require": { @@ -643,9 +579,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/1.1.2" + "source": "https://github.com/doctrine/deprecations/tree/1.1.3" }, - "time": "2023-09-27T20:04:15+00:00" + "time": "2024-01-30T19:34:25+00:00" }, { "name": "doctrine/instantiator", @@ -653,25 +589,25 @@ "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "f49f6a836a816609c853718ba2ea422dc18a8e4a" + "reference": "6c0ee619435c5d4f3bc515ab1514cf4cf1006c6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f49f6a836a816609c853718ba2ea422dc18a8e4a", - "reference": "f49f6a836a816609c853718ba2ea422dc18a8e4a", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/6c0ee619435c5d4f3bc515ab1514cf4cf1006c6e", + "reference": "6c0ee619435c5d4f3bc515ab1514cf4cf1006c6e", "shasum": "" }, "require": { "php": "^8.1" }, "require-dev": { - "doctrine/coding-standard": "^11", + "doctrine/coding-standard": "^12", "ext-pdo": "*", "ext-phar": "*", "phpbench/phpbench": "^1.2", "phpstan/phpstan": "^1.9.4", "phpstan/phpstan-phpunit": "^1.3", - "phpunit/phpunit": "^10.1.0", + "phpunit/phpunit": "^10.5", "vimeo/psalm": "^5.4" }, "default-branch": true, @@ -716,7 +652,7 @@ "type": "tidelift" } ], - "time": "2023-08-24T20:23:35+00:00" + "time": "2023-12-09T14:19:21+00:00" }, { "name": "felixfbecker/advanced-json-rpc", @@ -820,18 +756,84 @@ }, "time": "2022-06-19T17:15:06+00:00" }, + { + "name": "laravel/pint", + "version": "v1.2.1", + "source": { + "type": "git", + "url": "https://github.com/laravel/pint.git", + "reference": "e60e2112ee779ce60f253695b273d1646a17d6f1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/pint/zipball/e60e2112ee779ce60f253695b273d1646a17d6f1", + "reference": "e60e2112ee779ce60f253695b273d1646a17d6f1", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-mbstring": "*", + "ext-tokenizer": "*", + "ext-xml": "*", + "php": "^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.11.0", + "illuminate/view": "^9.32.0", + "laravel-zero/framework": "^9.2.0", + "mockery/mockery": "^1.5.1", + "nunomaduro/larastan": "^2.2.0", + "nunomaduro/termwind": "^1.14.0", + "pestphp/pest": "^1.22.1" + }, + "bin": [ + "builds/pint" + ], + "type": "project", + "autoload": { + "psr-4": { + "App\\": "app/", + "Database\\Seeders\\": "database/seeders/", + "Database\\Factories\\": "database/factories/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "An opinionated code formatter for PHP.", + "homepage": "https://laravel.com", + "keywords": [ + "format", + "formatter", + "lint", + "linter", + "php" + ], + "support": { + "issues": "https://github.com/laravel/pint/issues", + "source": "https://github.com/laravel/pint" + }, + "time": "2022-11-29T16:25:20+00:00" + }, { "name": "myclabs/deep-copy", "version": "1.x-dev", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "f6f48cfecf52ab791fe18cc1b11d6345512dc4b8" + "reference": "2f5294676c802a62b0549f6bc8983f14294ce369" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/f6f48cfecf52ab791fe18cc1b11d6345512dc4b8", - "reference": "f6f48cfecf52ab791fe18cc1b11d6345512dc4b8", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/2f5294676c802a62b0549f6bc8983f14294ce369", + "reference": "2f5294676c802a62b0549f6bc8983f14294ce369", "shasum": "" }, "require": { @@ -879,7 +881,7 @@ "type": "tidelift" } ], - "time": "2023-07-30T10:01:33+00:00" + "time": "2024-02-10T11:10:03+00:00" }, { "name": "netresearch/jsonmapper", @@ -938,17 +940,17 @@ "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "54103d838734be0499172026525e38cbf6af2711" + "reference": "c2403aa729cff7dade2fea55ff77d262840b2371" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/54103d838734be0499172026525e38cbf6af2711", - "reference": "54103d838734be0499172026525e38cbf6af2711", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/c2403aa729cff7dade2fea55ff77d262840b2371", + "reference": "c2403aa729cff7dade2fea55ff77d262840b2371", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=7.0" + "php": ">=7.1" }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", @@ -986,7 +988,7 @@ "issues": "https://github.com/nikic/PHP-Parser/issues", "source": "https://github.com/nikic/PHP-Parser/tree/4.x" }, - "time": "2023-10-03T21:00:18+00:00" + "time": "2024-03-02T17:21:59+00:00" }, { "name": "openlss/lib-array2xml", @@ -1047,12 +1049,12 @@ "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", - "reference": "67729272c564ab9f953c81f48db44e8b1cb1e1c3" + "reference": "54750ef60c58e43759730615a392c31c80e23176" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/67729272c564ab9f953c81f48db44e8b1cb1e1c3", - "reference": "67729272c564ab9f953c81f48db44e8b1cb1e1c3", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176", + "reference": "54750ef60c58e43759730615a392c31c80e23176", "shasum": "" }, "require": { @@ -1061,7 +1063,7 @@ "ext-phar": "*", "ext-xmlwriter": "*", "phar-io/version": "^3.0.1", - "php": "^7.3 || ^8.0" + "php": "^7.2 || ^8.0" }, "default-branch": true, "type": "library", @@ -1099,7 +1101,7 @@ "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", "support": { "issues": "https://github.com/phar-io/manifest/issues", - "source": "https://github.com/phar-io/manifest/tree/master" + "source": "https://github.com/phar-io/manifest/tree/2.0.4" }, "funding": [ { @@ -1107,7 +1109,7 @@ "type": "github" } ], - "time": "2023-06-01T14:19:47+00:00" + "time": "2024-03-03T12:33:53+00:00" }, { "name": "phar-io/version", @@ -1219,19 +1221,19 @@ "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "7b217217725dc991a0ae7b995041cee1d5019561" + "reference": "0b48e261e0a7bcbf1bd118ffd08e52ea6cfd34af" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/7b217217725dc991a0ae7b995041cee1d5019561", - "reference": "7b217217725dc991a0ae7b995041cee1d5019561", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/0b48e261e0a7bcbf1bd118ffd08e52ea6cfd34af", + "reference": "0b48e261e0a7bcbf1bd118ffd08e52ea6cfd34af", "shasum": "" }, "require": { "ext-filter": "*", "php": "^7.2 || ^8.0", "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "1.x-dev@dev", + "phpdocumentor/type-resolver": "^1.7", "phpstan/phpdoc-parser": "^1.7", "webmozart/assert": "^1.9.1" }, @@ -1267,7 +1269,7 @@ }, { "name": "Jaap van Otterdijk", - "email": "account@ijaap.nl" + "email": "opensource@ijaap.nl" } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", @@ -1275,7 +1277,7 @@ "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" }, - "time": "2023-03-12T10:50:44+00:00" + "time": "2024-01-26T20:33:24+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -1283,17 +1285,17 @@ "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419" + "reference": "153ae662783729388a584b4361f2545e4d841e3c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", - "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/153ae662783729388a584b4361f2545e4d841e3c", + "reference": "153ae662783729388a584b4361f2545e4d841e3c", "shasum": "" }, "require": { "doctrine/deprecations": "^1.0", - "php": "^7.4 || ^8.0", + "php": "^7.3 || ^8.0", "phpdocumentor/reflection-common": "^2.0", "phpstan/phpdoc-parser": "^1.13" }, @@ -1332,22 +1334,22 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.3" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.8.2" }, - "time": "2023-08-12T11:01:26+00:00" + "time": "2024-02-23T11:10:43+00:00" }, { "name": "phpstan/phpdoc-parser", - "version": "1.24.2", + "version": "1.26.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "bcad8d995980440892759db0c32acae7c8e79442" + "reference": "231e3186624c03d7e7c890ec662b81e6b0405227" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bcad8d995980440892759db0c32acae7c8e79442", - "reference": "bcad8d995980440892759db0c32acae7c8e79442", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/231e3186624c03d7e7c890ec662b81e6b0405227", + "reference": "231e3186624c03d7e7c890ec662b81e6b0405227", "shasum": "" }, "require": { @@ -1379,9 +1381,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.2" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.26.0" }, - "time": "2023-09-26T12:28:12+00:00" + "time": "2024-02-23T16:05:55+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1389,19 +1391,19 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "0b6cb84a359426d34e439ce6d1173b41e07cb672" + "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/0b6cb84a359426d34e439ce6d1173b41e07cb672", - "reference": "0b6cb84a359426d34e439ce6d1173b41e07cb672", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/48c34b5d8d983006bd2adc2d0de92963b9155965", + "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.15", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3", "phpunit/php-file-iterator": "^3.0.3", "phpunit/php-text-template": "^2.0.2", @@ -1451,7 +1453,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.31" }, "funding": [ { @@ -1459,7 +1461,7 @@ "type": "github" } ], - "time": "2023-10-06T09:53:04+00:00" + "time": "2024-03-02T06:37:42+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1708,12 +1710,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "18a76cf7293527f275342720eeb063dff346c97e" + "reference": "5b92d2809fe6c9dbf892e8016df656f16ef157e1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/18a76cf7293527f275342720eeb063dff346c97e", - "reference": "18a76cf7293527f275342720eeb063dff346c97e", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5b92d2809fe6c9dbf892e8016df656f16ef157e1", + "reference": "5b92d2809fe6c9dbf892e8016df656f16ef157e1", "shasum": "" }, "require": { @@ -1803,7 +1805,7 @@ "type": "tidelift" } ], - "time": "2023-10-06T09:52:37+00:00" + "time": "2024-03-06T06:47:12+00:00" }, { "name": "psr/container", @@ -1911,16 +1913,16 @@ }, { "name": "sebastian/cli-parser", - "version": "1.0.1", + "version": "1.0.x-dev", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/2b56bea83a09de3ac06bb18b92f068e60cc6f50b", + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b", "shasum": "" }, "require": { @@ -1955,7 +1957,7 @@ "homepage": "https://github.com/sebastianbergmann/cli-parser", "support": { "issues": "https://github.com/sebastianbergmann/cli-parser/issues", - "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.2" }, "funding": [ { @@ -1963,7 +1965,7 @@ "type": "github" } ], - "time": "2020-09-28T06:08:49+00:00" + "time": "2024-03-02T06:27:43+00:00" }, { "name": "sebastian/code-unit", @@ -2152,20 +2154,20 @@ }, { "name": "sebastian/complexity", - "version": "2.0.2", + "version": "2.0.x-dev", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/25f207c40d62b8b7aa32f5ab026c53561964053a", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a", "shasum": "" }, "require": { - "nikic/php-parser": "^4.7", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3" }, "require-dev": { @@ -2197,7 +2199,7 @@ "homepage": "https://github.com/sebastianbergmann/complexity", "support": { "issues": "https://github.com/sebastianbergmann/complexity/issues", - "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.3" }, "funding": [ { @@ -2205,7 +2207,7 @@ "type": "github" } ], - "time": "2020-10-26T15:52:27+00:00" + "time": "2023-12-22T06:19:30+00:00" }, { "name": "sebastian/diff", @@ -2213,12 +2215,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131" + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/74be17022044ebaaecfdf0c5cd504fc9cd5a7131", - "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc", "shasum": "" }, "require": { @@ -2263,7 +2265,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/4.0" + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.6" }, "funding": [ { @@ -2271,7 +2273,7 @@ "type": "github" } ], - "time": "2023-05-07T05:35:17+00:00" + "time": "2024-03-02T06:30:58+00:00" }, { "name": "sebastian/environment", @@ -2342,12 +2344,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d" + "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", - "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/78c00df8f170e02473b682df15bfcdacc3d32d72", + "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72", "shasum": "" }, "require": { @@ -2403,7 +2405,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/4.0" + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.6" }, "funding": [ { @@ -2411,7 +2413,7 @@ "type": "github" } ], - "time": "2022-09-14T06:03:37+00:00" + "time": "2024-03-02T06:33:00+00:00" }, { "name": "sebastian/global-state", @@ -2419,12 +2421,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bde739e7565280bda77be70044ac1047bc007e34" + "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bde739e7565280bda77be70044ac1047bc007e34", - "reference": "bde739e7565280bda77be70044ac1047bc007e34", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", + "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", "shasum": "" }, "require": { @@ -2467,7 +2469,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.7" }, "funding": [ { @@ -2475,24 +2477,24 @@ "type": "github" } ], - "time": "2023-08-02T09:26:13+00:00" + "time": "2024-03-02T06:35:11+00:00" }, { "name": "sebastian/lines-of-code", - "version": "1.0.3", + "version": "1.0.x-dev", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5", "shasum": "" }, "require": { - "nikic/php-parser": "^4.6", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3" }, "require-dev": { @@ -2524,7 +2526,7 @@ "homepage": "https://github.com/sebastianbergmann/lines-of-code", "support": { "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.4" }, "funding": [ { @@ -2532,7 +2534,7 @@ "type": "github" } ], - "time": "2020-11-28T06:42:11+00:00" + "time": "2023-12-22T06:20:34+00:00" }, { "name": "sebastian/object-enumerator", @@ -2879,12 +2881,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "f4f71842f24c2023b91237c72a365306f3c58827" + "reference": "39f75d9d73d0c11952fdcecf4877b4d0f62a8f6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/f4f71842f24c2023b91237c72a365306f3c58827", - "reference": "f4f71842f24c2023b91237c72a365306f3c58827", + "url": "https://api.github.com/repos/symfony/console/zipball/39f75d9d73d0c11952fdcecf4877b4d0f62a8f6e", + "reference": "39f75d9d73d0c11952fdcecf4877b4d0f62a8f6e", "shasum": "" }, "require": { @@ -2970,7 +2972,7 @@ "type": "tidelift" } ], - "time": "2023-08-07T06:12:30+00:00" + "time": "2024-02-20T16:33:57+00:00" }, { "name": "symfony/deprecation-contracts", @@ -2978,12 +2980,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" + "reference": "2c438b99bb2753c1628c1e6f523991edea5b03a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", - "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/2c438b99bb2753c1628c1e6f523991edea5b03a4", + "reference": "2c438b99bb2753c1628c1e6f523991edea5b03a4", "shasum": "" }, "require": { @@ -2993,7 +2995,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.4-dev" + "dev-main": "3.5-dev" }, "thanks": { "name": "symfony/contracts", @@ -3022,7 +3024,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.3.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/main" }, "funding": [ { @@ -3038,7 +3040,7 @@ "type": "tidelift" } ], - "time": "2023-05-23T14:45:45+00:00" + "time": "2024-01-02T14:07:37+00:00" }, { "name": "symfony/polyfill-ctype", @@ -3046,12 +3048,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb" + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", - "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4", + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4", "shasum": "" }, "require": { @@ -3066,9 +3068,6 @@ "default-branch": true, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -3105,7 +3104,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0" }, "funding": [ { @@ -3121,7 +3120,7 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-intl-grapheme", @@ -3129,12 +3128,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "875e90aeea2777b6f135677f618529449334a612" + "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/875e90aeea2777b6f135677f618529449334a612", - "reference": "875e90aeea2777b6f135677f618529449334a612", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/32a9da87d7b3245e09ac426c83d334ae9f06f80f", + "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f", "shasum": "" }, "require": { @@ -3146,9 +3145,6 @@ "default-branch": true, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -3187,7 +3183,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.29.0" }, "funding": [ { @@ -3203,7 +3199,7 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-intl-normalizer", @@ -3211,12 +3207,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92" + "reference": "bc45c394692b948b4d383a08d7753968bed9a83d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", - "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/bc45c394692b948b4d383a08d7753968bed9a83d", + "reference": "bc45c394692b948b4d383a08d7753968bed9a83d", "shasum": "" }, "require": { @@ -3228,9 +3224,6 @@ "default-branch": true, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -3272,7 +3265,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.29.0" }, "funding": [ { @@ -3288,7 +3281,7 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -3296,12 +3289,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "42292d99c55abe617799667f454222c54c60e229" + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229", - "reference": "42292d99c55abe617799667f454222c54c60e229", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", "shasum": "" }, "require": { @@ -3316,9 +3309,6 @@ "default-branch": true, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -3356,7 +3346,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" }, "funding": [ { @@ -3372,7 +3362,7 @@ "type": "tidelift" } ], - "time": "2023-07-28T09:04:16+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-php73", @@ -3380,12 +3370,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "fe2f306d1d9d346a7fee353d0d5012e401e984b5" + "reference": "21bd091060673a1177ae842c0ef8fe30893114d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fe2f306d1d9d346a7fee353d0d5012e401e984b5", - "reference": "fe2f306d1d9d346a7fee353d0d5012e401e984b5", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/21bd091060673a1177ae842c0ef8fe30893114d2", + "reference": "21bd091060673a1177ae842c0ef8fe30893114d2", "shasum": "" }, "require": { @@ -3394,9 +3384,6 @@ "default-branch": true, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -3436,7 +3423,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.29.0" }, "funding": [ { @@ -3452,7 +3439,7 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-php80", @@ -3460,12 +3447,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" + "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5", - "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", + "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", "shasum": "" }, "require": { @@ -3474,9 +3461,6 @@ "default-branch": true, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -3520,7 +3504,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0" }, "funding": [ { @@ -3536,7 +3520,7 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/service-contracts", @@ -3544,17 +3528,17 @@ "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "a4025a1c812c231d88ed0780e866b0cc644f4a84" + "reference": "cea2eccfcd27ac3deb252bd67f78b9b8ffc4da84" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/a4025a1c812c231d88ed0780e866b0cc644f4a84", - "reference": "a4025a1c812c231d88ed0780e866b0cc644f4a84", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/cea2eccfcd27ac3deb252bd67f78b9b8ffc4da84", + "reference": "cea2eccfcd27ac3deb252bd67f78b9b8ffc4da84", "shasum": "" }, "require": { "php": ">=8.1", - "psr/container": "^2.0" + "psr/container": "^1.1|^2.0" }, "conflict": { "ext-psr": "<1.1|>=2" @@ -3563,7 +3547,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.4-dev" + "dev-main": "3.5-dev" }, "thanks": { "name": "symfony/contracts", @@ -3619,7 +3603,7 @@ "type": "tidelift" } ], - "time": "2023-07-29T13:12:44+00:00" + "time": "2024-01-02T14:07:37+00:00" }, { "name": "symfony/string", @@ -3627,12 +3611,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "742351f7542c9b9799873e399a716cb5af6f70f2" + "reference": "4e465a95bdc32f49cf4c7f07f751b843bbd6dcd9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/742351f7542c9b9799873e399a716cb5af6f70f2", - "reference": "742351f7542c9b9799873e399a716cb5af6f70f2", + "url": "https://api.github.com/repos/symfony/string/zipball/4e465a95bdc32f49cf4c7f07f751b843bbd6dcd9", + "reference": "4e465a95bdc32f49cf4c7f07f751b843bbd6dcd9", "shasum": "" }, "require": { @@ -3705,20 +3689,20 @@ "type": "tidelift" } ], - "time": "2023-09-18T10:40:25+00:00" + "time": "2024-02-01T13:16:41+00:00" }, { "name": "theseer/tokenizer", - "version": "1.2.1", + "version": "1.2.3", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", "shasum": "" }, "require": { @@ -3747,7 +3731,7 @@ "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "support": { "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/1.2.1" + "source": "https://github.com/theseer/tokenizer/tree/1.2.3" }, "funding": [ { @@ -3755,7 +3739,7 @@ "type": "github" } ], - "time": "2021-07-28T10:34:58+00:00" + "time": "2024-03-03T12:36:25+00:00" }, { "name": "vimeo/psalm", @@ -3917,16 +3901,16 @@ }, { "name": "webmozart/glob", - "version": "4.7.x-dev", + "version": "4.8.x-dev", "source": { "type": "git", "url": "https://github.com/webmozarts/glob.git", - "reference": "3c17f7dec3d9d0e87b575026011f2e75a56ed655" + "reference": "8a2842112d6916e61e0e15e316465b611f3abc17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozarts/glob/zipball/3c17f7dec3d9d0e87b575026011f2e75a56ed655", - "reference": "3c17f7dec3d9d0e87b575026011f2e75a56ed655", + "url": "https://api.github.com/repos/webmozarts/glob/zipball/8a2842112d6916e61e0e15e316465b611f3abc17", + "reference": "8a2842112d6916e61e0e15e316465b611f3abc17", "shasum": "" }, "require": { @@ -3936,7 +3920,6 @@ "phpunit/phpunit": "^9.5", "symfony/filesystem": "^5.3" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -3961,9 +3944,9 @@ "description": "A PHP implementation of Ant's glob.", "support": { "issues": "https://github.com/webmozarts/glob/issues", - "source": "https://github.com/webmozarts/glob/tree/4.6.0" + "source": "https://github.com/webmozarts/glob/tree/4.7.0" }, - "time": "2022-05-24T19:45:58+00:00" + "time": "2024-03-07T20:33:40+00:00" }, { "name": "webmozart/path-util", @@ -4034,5 +4017,5 @@ "php": ">=8.0" }, "platform-dev": [], - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.6.0" } diff --git a/src/Storage/Validator/File.php b/src/Storage/Validator/File.php index c8ffe95e..0bc4cd2d 100644 --- a/src/Storage/Validator/File.php +++ b/src/Storage/Validator/File.php @@ -2,7 +2,7 @@ namespace Utopia\Storage\Validator; -use Utopia\Validator; +use Utopia\Http\Validator; class File extends Validator { diff --git a/src/Storage/Validator/FileExt.php b/src/Storage/Validator/FileExt.php index ee121068..62f575a0 100644 --- a/src/Storage/Validator/FileExt.php +++ b/src/Storage/Validator/FileExt.php @@ -2,7 +2,7 @@ namespace Utopia\Storage\Validator; -use Utopia\Validator; +use Utopia\Http\Validator; class FileExt extends Validator { diff --git a/src/Storage/Validator/FileName.php b/src/Storage/Validator/FileName.php index 7a1885e8..b263e6f4 100644 --- a/src/Storage/Validator/FileName.php +++ b/src/Storage/Validator/FileName.php @@ -2,7 +2,7 @@ namespace Utopia\Storage\Validator; -use Utopia\Validator; +use Utopia\Http\Validator; class FileName extends Validator { diff --git a/src/Storage/Validator/FileSize.php b/src/Storage/Validator/FileSize.php index e31aa4c6..e133d067 100644 --- a/src/Storage/Validator/FileSize.php +++ b/src/Storage/Validator/FileSize.php @@ -2,7 +2,7 @@ namespace Utopia\Storage\Validator; -use Utopia\Validator; +use Utopia\Http\Validator; class FileSize extends Validator { diff --git a/src/Storage/Validator/FileType.php b/src/Storage/Validator/FileType.php index 9385f360..a5e366bc 100644 --- a/src/Storage/Validator/FileType.php +++ b/src/Storage/Validator/FileType.php @@ -3,7 +3,7 @@ namespace Utopia\Storage\Validator; use Exception; -use Utopia\Validator; +use Utopia\Http\Validator; class FileType extends Validator { diff --git a/src/Storage/Validator/Upload.php b/src/Storage/Validator/Upload.php index d3a70918..139d46e4 100644 --- a/src/Storage/Validator/Upload.php +++ b/src/Storage/Validator/Upload.php @@ -2,7 +2,7 @@ namespace Utopia\Storage\Validator; -use Utopia\Validator; +use Utopia\Http\Validator; class Upload extends Validator { From c03df5548aba6fea5d15485ffcbee779b8aea9cb Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 2 Apr 2024 06:24:32 +0000 Subject: [PATCH 091/117] allow setting http version in s3 adapter --- src/Storage/Device/S3.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 79aadeff..a182a1b1 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -26,6 +26,14 @@ class S3 extends Device const METHOD_TRACE = 'TRACE'; + const HTTP_VERSION_1_1 = CURL_HTTP_VERSION_1_1; + + const HTTP_VERSION_2_0 = CURL_HTTP_VERSION_2_0; + + const HTTP_VERSION_2 = CURL_HTTP_VERSION_2; + + const HTTP_VERSION_1_0 = CURL_HTTP_VERSION_1_0; + /** * AWS Regions constants */ @@ -138,6 +146,13 @@ class S3 extends Device */ protected array $amzHeaders; + /** + * Http version + * + * @var int|null + */ + protected ?int $curlHttpVersion = null; + /** * S3 Constructor * @@ -208,6 +223,20 @@ public function getPath(string $filename, string $prefix = null): string return $this->getRoot().DIRECTORY_SEPARATOR.$filename; } + /** + * Set http version + * + * + * @param int|null $httpVersion + * @return self + */ + public function setHttpVersion(?int $httpVersion): self + { + $this->curlHttpVersion = $httpVersion; + + return $this; + } + /** * Upload. * @@ -837,6 +866,11 @@ private function call(string $method, string $uri, string $data = '', array $par \curl_setopt($curl, CURLOPT_HTTPHEADER, $httpHeaders); \curl_setopt($curl, CURLOPT_HEADER, false); \curl_setopt($curl, CURLOPT_RETURNTRANSFER, false); + + if ($this->curlHttpVersion != null) { + \curl_setopt($curl, CURLOPT_HTTP_VERSION, $this->curlHttpVersion); + } + \curl_setopt($curl, CURLOPT_WRITEFUNCTION, function ($curl, string $data) use ($response) { $response->body .= $data; From 7c0a7625e9de338e3f92edc40fc2a8ad3d371b66 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 2 Apr 2024 06:51:58 +0000 Subject: [PATCH 092/117] override listobjects in backblaze --- src/Storage/Device/Backblaze.php | 36 ++++++++++++++++++++++++++++++++ src/Storage/Device/S3.php | 4 ++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/Storage/Device/Backblaze.php b/src/Storage/Device/Backblaze.php index 7420098e..0c0ecb36 100644 --- a/src/Storage/Device/Backblaze.php +++ b/src/Storage/Device/Backblaze.php @@ -2,6 +2,7 @@ namespace Utopia\Storage\Device; +use Exception; use Utopia\Storage\Storage; class Backblaze extends S3 @@ -61,4 +62,39 @@ public function getType(): string { return Storage::DEVICE_BACKBLAZE; } + + /** + * Get list of objects in the given path. + * + * @param string $prefix + * @param int $maxKeys + * @param string $continuationToken + * @return array + * + * @throws Exception + */ + protected function listObjects(string $prefix = '', int $maxKeys = self::MAX_PAGE_SIZE, string $continuationToken = ''): array + { + if ($maxKeys > S3::MAX_PAGE_SIZE) { + throw new Exception('Cannot list more than '.S3::MAX_PAGE_SIZE.' objects'); + } + + $uri = '/'; + $prefix = ltrim($prefix, '/'); /** S3 specific requirement that prefix should never contain a leading slash */ + $this->headers['content-type'] = 'text/plain'; + $this->headers['content-md5'] = \base64_encode(md5('', true)); + + $parameters = [ + 'prefix' => $prefix, + 'max-keys' => $maxKeys, + ]; + + if (! empty($continuationToken)) { + $parameters['continuation-token'] = $continuationToken; + } + + $response = $this->call(S3::METHOD_GET, $uri, '', $parameters); + + return $response->body; + } } diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index a182a1b1..9d459979 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -512,7 +512,7 @@ public function delete(string $path, bool $recursive = false): bool * * @throws Exception */ - private function listObjects(string $prefix = '', int $maxKeys = self::MAX_PAGE_SIZE, string $continuationToken = ''): array + protected function listObjects(string $prefix = '', int $maxKeys = self::MAX_PAGE_SIZE, string $continuationToken = ''): array { if ($maxKeys > self::MAX_PAGE_SIZE) { throw new Exception('Cannot list more than '.self::MAX_PAGE_SIZE.' objects'); @@ -826,7 +826,7 @@ private function getSignatureV4(string $method, string $uri, array $parameters = * * @throws \Exception */ - private function call(string $method, string $uri, string $data = '', array $parameters = [], bool $decode = true) + protected function call(string $method, string $uri, string $data = '', array $parameters = [], bool $decode = true) { $uri = $this->getAbsolutePath($uri); $url = 'https://'.$this->headers['host'].$uri.'?'.\http_build_query($parameters, '', '&', PHP_QUERY_RFC3986); From 200d648acd6268983b69d14ef50e72f821dc873e Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 2 Apr 2024 07:52:00 +0000 Subject: [PATCH 093/117] reset backblaze adapter --- src/Storage/Device/Backblaze.php | 35 -------------------------------- 1 file changed, 35 deletions(-) diff --git a/src/Storage/Device/Backblaze.php b/src/Storage/Device/Backblaze.php index 0c0ecb36..9a244482 100644 --- a/src/Storage/Device/Backblaze.php +++ b/src/Storage/Device/Backblaze.php @@ -62,39 +62,4 @@ public function getType(): string { return Storage::DEVICE_BACKBLAZE; } - - /** - * Get list of objects in the given path. - * - * @param string $prefix - * @param int $maxKeys - * @param string $continuationToken - * @return array - * - * @throws Exception - */ - protected function listObjects(string $prefix = '', int $maxKeys = self::MAX_PAGE_SIZE, string $continuationToken = ''): array - { - if ($maxKeys > S3::MAX_PAGE_SIZE) { - throw new Exception('Cannot list more than '.S3::MAX_PAGE_SIZE.' objects'); - } - - $uri = '/'; - $prefix = ltrim($prefix, '/'); /** S3 specific requirement that prefix should never contain a leading slash */ - $this->headers['content-type'] = 'text/plain'; - $this->headers['content-md5'] = \base64_encode(md5('', true)); - - $parameters = [ - 'prefix' => $prefix, - 'max-keys' => $maxKeys, - ]; - - if (! empty($continuationToken)) { - $parameters['continuation-token'] = $continuationToken; - } - - $response = $this->call(S3::METHOD_GET, $uri, '', $parameters); - - return $response->body; - } } From 94fb54c508a247098d2ea0baeacbd04dc7916fb9 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 2 Apr 2024 07:54:15 +0000 Subject: [PATCH 094/117] update test bucket --- tests/Storage/Device/BackblazeTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Storage/Device/BackblazeTest.php b/tests/Storage/Device/BackblazeTest.php index 91ce2f8f..d2d277b4 100644 --- a/tests/Storage/Device/BackblazeTest.php +++ b/tests/Storage/Device/BackblazeTest.php @@ -12,7 +12,7 @@ protected function init(): void $this->root = '/root'; $key = $_SERVER['BACKBLAZE_ACCESS_KEY'] ?? ''; $secret = $_SERVER['BACKBLAZE_SECRET'] ?? ''; - $bucket = 'utopia-storage-test'; + $bucket = 'utopia-storage-test-new'; $this->object = new Backblaze($this->root, $key, $secret, $bucket, Backblaze::US_WEST_004, Backblaze::ACL_PRIVATE); } From 266e3b37a49425e3724be9107972f94a006002d6 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 2 Apr 2024 07:57:04 +0000 Subject: [PATCH 095/117] fix linter --- src/Storage/Device/Backblaze.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Storage/Device/Backblaze.php b/src/Storage/Device/Backblaze.php index 9a244482..7420098e 100644 --- a/src/Storage/Device/Backblaze.php +++ b/src/Storage/Device/Backblaze.php @@ -2,7 +2,6 @@ namespace Utopia\Storage\Device; -use Exception; use Utopia\Storage\Storage; class Backblaze extends S3 From 3fa618d04e5b88f12855e2a5af0678b4ac33bbc7 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 2 Apr 2024 08:08:00 +0000 Subject: [PATCH 096/117] unset headers --- test.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test.php diff --git a/test.php b/test.php new file mode 100644 index 00000000..c795020b --- /dev/null +++ b/test.php @@ -0,0 +1,26 @@ +upload('./Bruce Wayne.png', $device->getPath('resting/test111.png')); +// var_dump($uploaded); + +$device->upload(__DIR__.'/tests/resources/disk-a/kitten-1.jpg', $device->getPath('testing/kitten-1.jpg')); +var_dump('uploaded'); +$device->upload(__DIR__.'/tests/resources/disk-a/kitten-2.jpg', $device->getPath('testing/kitten-2.jpg')); +var_dump('uploaded'); +$device->upload(__DIR__.'/tests/resources/disk-b/kitten-1.png', $device->getPath('testing/kitten-1.png')); +var_dump('uploaded'); +$device->upload(__DIR__.'/tests/resources/disk-b/kitten-2.png', $device->getPath('testing/kitten-2.png')); +var_dump('uploaded'); + +$path = $device->getPath('testing/'); +$files = $device->getFiles($path); +var_dump($files); \ No newline at end of file From 556a0218cf766ac1146652be4c840e29b68b0c67 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 2 Apr 2024 08:08:06 +0000 Subject: [PATCH 097/117] fix linter --- src/Storage/Device/S3.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 9d459979..f01dc159 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -523,6 +523,9 @@ protected function listObjects(string $prefix = '', int $maxKeys = self::MAX_PAG $this->headers['content-type'] = 'text/plain'; $this->headers['content-md5'] = \base64_encode(md5('', true)); + unset($this->amzHeaders['x-amz-content-sha256']); + unset($this->amzHeaders['x-amz-acl']); + $parameters = [ 'list-type' => 2, 'prefix' => $prefix, From 33ea0fb1c1e9d57fa18065aa728de677faa58fee Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 2 Apr 2024 08:10:33 +0000 Subject: [PATCH 098/117] remove file --- test.php | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 test.php diff --git a/test.php b/test.php deleted file mode 100644 index c795020b..00000000 --- a/test.php +++ /dev/null @@ -1,26 +0,0 @@ -upload('./Bruce Wayne.png', $device->getPath('resting/test111.png')); -// var_dump($uploaded); - -$device->upload(__DIR__.'/tests/resources/disk-a/kitten-1.jpg', $device->getPath('testing/kitten-1.jpg')); -var_dump('uploaded'); -$device->upload(__DIR__.'/tests/resources/disk-a/kitten-2.jpg', $device->getPath('testing/kitten-2.jpg')); -var_dump('uploaded'); -$device->upload(__DIR__.'/tests/resources/disk-b/kitten-1.png', $device->getPath('testing/kitten-1.png')); -var_dump('uploaded'); -$device->upload(__DIR__.'/tests/resources/disk-b/kitten-2.png', $device->getPath('testing/kitten-2.png')); -var_dump('uploaded'); - -$path = $device->getPath('testing/'); -$files = $device->getFiles($path); -var_dump($files); \ No newline at end of file From 3ad32bd705c53e5eda33f80e70b8ea305fd9cd8e Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 2 Apr 2024 08:50:52 +0000 Subject: [PATCH 099/117] fix double --- src/Storage/Device/S3.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 3fb9f59d..c319bc57 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -525,8 +525,6 @@ protected function listObjects(string $prefix = '', int $maxKeys = self::MAX_PAG $uri = '/'; $prefix = ltrim($prefix, '/'); /** S3 specific requirement that prefix should never contain a leading slash */ - unset($this->amzHeaders['x-amz-acl']); - unset($this->amzHeaders['x-amz-content-sha256']); $this->headers['content-type'] = 'text/plain'; $this->headers['content-md5'] = \base64_encode(md5('', true)); From dffcbe0be08c8114750e6af4f682ae965e3791ea Mon Sep 17 00:00:00 2001 From: Binyamin Yawitz <316103+byawitz@users.noreply.github.com> Date: Fri, 9 Aug 2024 17:00:39 -0400 Subject: [PATCH 100/117] chore: updating versions --- composer.json | 4 +- composer.lock | 577 ++++++++++++++++++++++++++++---------------------- 2 files changed, 330 insertions(+), 251 deletions(-) diff --git a/composer.json b/composer.json index 080f1557..540f1f78 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "ext-lz4": "*", "ext-snappy": "*", "php": ">=8.0", - "utopia-php/framework": "0.34.*", + "utopia-php/framework": "1.0.*", "utopia-php/system": "0.*.*" }, "require-dev": { @@ -32,5 +32,5 @@ "vimeo/psalm": "4.0.1", "laravel/pint": "1.2.*" }, - "minimum-stability": "dev" + "minimum-stability": "RC" } diff --git a/composer.lock b/composer.lock index 0a0fb5c2..be75e48b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,27 +4,77 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a2a5687c81b47dd5385eb0db14b6bb06", + "content-hash": "cf7e55fc0344e71e130f62fdd788835b", "packages": [ + { + "name": "utopia-php/di", + "version": "0.1.0", + "source": { + "type": "git", + "url": "https://github.com/utopia-php/di.git", + "reference": "22490c95f7ac3898ed1c33f1b1b5dd577305ee31" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/utopia-php/di/zipball/22490c95f7ac3898ed1c33f1b1b5dd577305ee31", + "reference": "22490c95f7ac3898ed1c33f1b1b5dd577305ee31", + "shasum": "" + }, + "require": { + "php": ">=8.2" + }, + "require-dev": { + "laravel/pint": "^1.2", + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9.5.25", + "swoole/ide-helper": "4.8.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Utopia\\": "src/", + "Tests\\E2E\\": "tests/e2e" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A simple and lite library for managing dependency injections", + "keywords": [ + "framework", + "http", + "php", + "upf" + ], + "support": { + "issues": "https://github.com/utopia-php/di/issues", + "source": "https://github.com/utopia-php/di/tree/0.1.0" + }, + "time": "2024-08-08T14:35:19+00:00" + }, { "name": "utopia-php/framework", - "version": "0.34.2", + "version": "1.0.0-RC2", "source": { "type": "git", "url": "https://github.com/utopia-php/http.git", - "reference": "fd126c02b78cc80678c9638f7b335dfb4a841b78" + "reference": "d1e9674dbf33bed03fa53854ec1f2c6e074cf4d7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/fd126c02b78cc80678c9638f7b335dfb4a841b78", - "reference": "fd126c02b78cc80678c9638f7b335dfb4a841b78", + "url": "https://api.github.com/repos/utopia-php/http/zipball/d1e9674dbf33bed03fa53854ec1f2c6e074cf4d7", + "reference": "d1e9674dbf33bed03fa53854ec1f2c6e074cf4d7", "shasum": "" }, "require": { "ext-swoole": "*", - "php": ">=8.0" + "php": ">=8.0", + "utopia-php/servers": "0.1.* " }, "require-dev": { + "ext-xdebug": "*", "laravel/pint": "^1.2", "phpbench/phpbench": "^1.2", "phpstan/phpstan": "^1.10", @@ -34,7 +84,7 @@ "type": "library", "autoload": { "psr-4": { - "Utopia\\Http\\": "src/Http" + "Utopia\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -50,22 +100,75 @@ ], "support": { "issues": "https://github.com/utopia-php/http/issues", - "source": "https://github.com/utopia-php/http/tree/0.34.2" + "source": "https://github.com/utopia-php/http/tree/1.0.0-RC2" + }, + "time": "2024-08-08T14:46:41+00:00" + }, + { + "name": "utopia-php/servers", + "version": "0.1.0", + "source": { + "type": "git", + "url": "https://github.com/utopia-php/servers.git", + "reference": "7d9e4f364fb1ab1889fb89ca96eb9946467cb09c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/utopia-php/servers/zipball/7d9e4f364fb1ab1889fb89ca96eb9946467cb09c", + "reference": "7d9e4f364fb1ab1889fb89ca96eb9946467cb09c", + "shasum": "" }, - "time": "2024-02-20T11:36:56+00:00" + "require": { + "php": ">=8.0", + "utopia-php/di": "0.1.*" + }, + "require-dev": { + "laravel/pint": "^0.2.3", + "phpstan/phpstan": "^1.8", + "phpunit/phpunit": "^9.5.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Utopia\\Servers\\": "src/Servers" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Team Appwrite", + "email": "team@appwrite.io" + } + ], + "description": "A base library for building Utopia style servers.", + "keywords": [ + "framework", + "php", + "servers", + "upf", + "utopia" + ], + "support": { + "issues": "https://github.com/utopia-php/servers/issues", + "source": "https://github.com/utopia-php/servers/tree/0.1.0" + }, + "time": "2024-08-08T14:31:39+00:00" }, { "name": "utopia-php/system", - "version": "0.7.2", + "version": "0.8.0", "source": { "type": "git", "url": "https://github.com/utopia-php/system.git", - "reference": "4593d4d334b0c15879c4744a826e0362924c5d66" + "reference": "a2cbfb3c69b9ecb8b6f06c5774f3cf279ea7665e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/system/zipball/4593d4d334b0c15879c4744a826e0362924c5d66", - "reference": "4593d4d334b0c15879c4744a826e0362924c5d66", + "url": "https://api.github.com/repos/utopia-php/system/zipball/a2cbfb3c69b9ecb8b6f06c5774f3cf279ea7665e", + "reference": "a2cbfb3c69b9ecb8b6f06c5774f3cf279ea7665e", "shasum": "" }, "require": { @@ -106,24 +209,24 @@ ], "support": { "issues": "https://github.com/utopia-php/system/issues", - "source": "https://github.com/utopia-php/system/tree/0.7.2" + "source": "https://github.com/utopia-php/system/tree/0.8.0" }, - "time": "2023-10-20T01:39:17+00:00" + "time": "2024-04-01T10:22:28+00:00" } ], "packages-dev": [ { "name": "amphp/amp", - "version": "2.x-dev", + "version": "v2.6.4", "source": { "type": "git", "url": "https://github.com/amphp/amp.git", - "reference": "c5ea79065f98f93f7b16a4d5a504fe5d69451447" + "reference": "ded3d9be08f526089eb7ee8d9f16a9768f9dec2d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/amp/zipball/c5ea79065f98f93f7b16a4d5a504fe5d69451447", - "reference": "c5ea79065f98f93f7b16a4d5a504fe5d69451447", + "url": "https://api.github.com/repos/amphp/amp/zipball/ded3d9be08f526089eb7ee8d9f16a9768f9dec2d", + "reference": "ded3d9be08f526089eb7ee8d9f16a9768f9dec2d", "shasum": "" }, "require": { @@ -135,8 +238,8 @@ "ext-json": "*", "jetbrains/phpstorm-stubs": "^2019.3", "phpunit/phpunit": "^7 | ^8 | ^9", - "psalm/phar": "^3.11@dev", - "react/promise": "^2" + "react/promise": "^2", + "vimeo/psalm": "^3.12" }, "type": "library", "extra": { @@ -191,7 +294,7 @@ "support": { "irc": "irc://irc.freenode.org/amphp", "issues": "https://github.com/amphp/amp/issues", - "source": "https://github.com/amphp/amp/tree/master" + "source": "https://github.com/amphp/amp/tree/v2.6.4" }, "funding": [ { @@ -199,20 +302,20 @@ "type": "github" } ], - "time": "2022-08-21T11:55:21+00:00" + "time": "2024-03-21T18:52:26+00:00" }, { "name": "amphp/byte-stream", - "version": "1.x-dev", + "version": "v1.8.2", "source": { "type": "git", "url": "https://github.com/amphp/byte-stream.git", - "reference": "18f86b65129d923e004df27e2a3d6f4159c3c743" + "reference": "4f0e968ba3798a423730f567b1b50d3441c16ddc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/byte-stream/zipball/18f86b65129d923e004df27e2a3d6f4159c3c743", - "reference": "18f86b65129d923e004df27e2a3d6f4159c3c743", + "url": "https://api.github.com/repos/amphp/byte-stream/zipball/4f0e968ba3798a423730f567b1b50d3441c16ddc", + "reference": "4f0e968ba3798a423730f567b1b50d3441c16ddc", "shasum": "" }, "require": { @@ -228,11 +331,6 @@ "psalm/phar": "^3.11.4" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, "autoload": { "files": [ "lib/functions.php" @@ -266,9 +364,8 @@ "stream" ], "support": { - "irc": "irc://irc.freenode.org/amphp", "issues": "https://github.com/amphp/byte-stream/issues", - "source": "https://github.com/amphp/byte-stream/tree/master" + "source": "https://github.com/amphp/byte-stream/tree/v1.8.2" }, "funding": [ { @@ -276,11 +373,11 @@ "type": "github" } ], - "time": "2022-06-21T18:19:50+00:00" + "time": "2024-04-13T18:00:56+00:00" }, { "name": "composer/package-versions-deprecated", - "version": "dev-master", + "version": "1.11.99.5", "source": { "type": "git", "url": "https://github.com/composer/package-versions-deprecated.git", @@ -304,7 +401,6 @@ "ext-zip": "^1.13", "phpunit/phpunit": "^6.5 || ^7" }, - "default-branch": true, "type": "composer-plugin", "extra": { "class": "PackageVersions\\Installer", @@ -354,16 +450,16 @@ }, { "name": "composer/semver", - "version": "dev-main", + "version": "3.4.2", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "1d09200268e7d1052ded8e5da9c73c96a63d18f5" + "reference": "c51258e759afdb17f1fd1fe83bc12baaef6309d6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/1d09200268e7d1052ded8e5da9c73c96a63d18f5", - "reference": "1d09200268e7d1052ded8e5da9c73c96a63d18f5", + "url": "https://api.github.com/repos/composer/semver/zipball/c51258e759afdb17f1fd1fe83bc12baaef6309d6", + "reference": "c51258e759afdb17f1fd1fe83bc12baaef6309d6", "shasum": "" }, "require": { @@ -373,7 +469,6 @@ "phpstan/phpstan": "^1.4", "symfony/phpunit-bridge": "^4.2 || ^5" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -416,7 +511,7 @@ "support": { "irc": "ircs://irc.libera.chat:6697/composer", "issues": "https://github.com/composer/semver/issues", - "source": "https://github.com/composer/semver/tree/main" + "source": "https://github.com/composer/semver/tree/3.4.2" }, "funding": [ { @@ -432,20 +527,20 @@ "type": "tidelift" } ], - "time": "2023-08-31T12:20:31+00:00" + "time": "2024-07-12T11:35:52+00:00" }, { "name": "composer/xdebug-handler", - "version": "1.4.x-dev", + "version": "1.4.6", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "dee81bf97571cb7168019825ee9522e8dc2a5936" + "reference": "f27e06cd9675801df441b3656569b328e04aa37c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/dee81bf97571cb7168019825ee9522e8dc2a5936", - "reference": "dee81bf97571cb7168019825ee9522e8dc2a5936", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/f27e06cd9675801df441b3656569b328e04aa37c", + "reference": "f27e06cd9675801df441b3656569b328e04aa37c", "shasum": "" }, "require": { @@ -480,7 +575,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/1.4" + "source": "https://github.com/composer/xdebug-handler/tree/1.4.6" }, "funding": [ { @@ -496,7 +591,7 @@ "type": "tidelift" } ], - "time": "2022-01-05T14:26:21+00:00" + "time": "2021-03-25T17:01:18+00:00" }, { "name": "dnoegel/php-xdg-base-dir", @@ -537,7 +632,7 @@ }, { "name": "doctrine/deprecations", - "version": "1.1.x-dev", + "version": "1.1.3", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", @@ -564,7 +659,6 @@ "suggest": { "psr/log": "Allows logging deprecations via PSR-3 logger implementation" }, - "default-branch": true, "type": "library", "autoload": { "psr-4": { @@ -585,32 +679,31 @@ }, { "name": "doctrine/instantiator", - "version": "2.0.x-dev", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "6c0ee619435c5d4f3bc515ab1514cf4cf1006c6e" + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/6c0ee619435c5d4f3bc515ab1514cf4cf1006c6e", - "reference": "6c0ee619435c5d4f3bc515ab1514cf4cf1006c6e", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", "shasum": "" }, "require": { "php": "^8.1" }, "require-dev": { - "doctrine/coding-standard": "^12", + "doctrine/coding-standard": "^11", "ext-pdo": "*", "ext-phar": "*", "phpbench/phpbench": "^1.2", "phpstan/phpstan": "^1.9.4", "phpstan/phpstan-phpunit": "^1.3", - "phpunit/phpunit": "^10.5", + "phpunit/phpunit": "^9.5.27", "vimeo/psalm": "^5.4" }, - "default-branch": true, "type": "library", "autoload": { "psr-4": { @@ -636,7 +729,7 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/2.0.x" + "source": "https://github.com/doctrine/instantiator/tree/2.0.0" }, "funding": [ { @@ -652,7 +745,7 @@ "type": "tidelift" } ], - "time": "2023-12-09T14:19:21+00:00" + "time": "2022-12-30T00:23:10+00:00" }, { "name": "felixfbecker/advanced-json-rpc", @@ -701,16 +794,16 @@ }, { "name": "felixfbecker/language-server-protocol", - "version": "dev-master", + "version": "v1.5.2", "source": { "type": "git", "url": "https://github.com/felixfbecker/php-language-server-protocol.git", - "reference": "ae4c490773bb0d21ca6f5e08a737506f44e175ea" + "reference": "6e82196ffd7c62f7794d778ca52b69feec9f2842" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/felixfbecker/php-language-server-protocol/zipball/ae4c490773bb0d21ca6f5e08a737506f44e175ea", - "reference": "ae4c490773bb0d21ca6f5e08a737506f44e175ea", + "url": "https://api.github.com/repos/felixfbecker/php-language-server-protocol/zipball/6e82196ffd7c62f7794d778ca52b69feec9f2842", + "reference": "6e82196ffd7c62f7794d778ca52b69feec9f2842", "shasum": "" }, "require": { @@ -721,7 +814,6 @@ "squizlabs/php_codesniffer": "^3.1", "vimeo/psalm": "^4.0" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -752,9 +844,9 @@ ], "support": { "issues": "https://github.com/felixfbecker/php-language-server-protocol/issues", - "source": "https://github.com/felixfbecker/php-language-server-protocol/tree/master" + "source": "https://github.com/felixfbecker/php-language-server-protocol/tree/v1.5.2" }, - "time": "2022-06-19T17:15:06+00:00" + "time": "2022-03-02T22:36:06+00:00" }, { "name": "laravel/pint", @@ -824,16 +916,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.x-dev", + "version": "1.12.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "2f5294676c802a62b0549f6bc8983f14294ce369" + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/2f5294676c802a62b0549f6bc8983f14294ce369", - "reference": "2f5294676c802a62b0549f6bc8983f14294ce369", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", "shasum": "" }, "require": { @@ -849,7 +941,6 @@ "phpspec/prophecy": "^1.10", "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" }, - "default-branch": true, "type": "library", "autoload": { "files": [ @@ -873,7 +964,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.x" + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.0" }, "funding": [ { @@ -881,7 +972,7 @@ "type": "tidelift" } ], - "time": "2024-02-10T11:10:03+00:00" + "time": "2024-06-12T14:39:25+00:00" }, { "name": "netresearch/jsonmapper", @@ -936,16 +1027,16 @@ }, { "name": "nikic/php-parser", - "version": "4.x-dev", + "version": "v4.19.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "c2403aa729cff7dade2fea55ff77d262840b2371" + "reference": "4e1b88d21c69391150ace211e9eaf05810858d0b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/c2403aa729cff7dade2fea55ff77d262840b2371", - "reference": "c2403aa729cff7dade2fea55ff77d262840b2371", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4e1b88d21c69391150ace211e9eaf05810858d0b", + "reference": "4e1b88d21c69391150ace211e9eaf05810858d0b", "shasum": "" }, "require": { @@ -986,9 +1077,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/4.x" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.19.1" }, - "time": "2024-03-02T17:21:59+00:00" + "time": "2024-03-17T08:10:35+00:00" }, { "name": "openlss/lib-array2xml", @@ -1045,7 +1136,7 @@ }, { "name": "phar-io/manifest", - "version": "dev-master", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", @@ -1065,7 +1156,6 @@ "phar-io/version": "^3.0.1", "php": "^7.2 || ^8.0" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -1164,25 +1254,25 @@ }, { "name": "phpdocumentor/reflection-common", - "version": "dev-master", + "version": "2.2.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "a0eeab580cbdf4414fef6978732510a36ed0a9d6" + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/a0eeab580cbdf4414fef6978732510a36ed0a9d6", - "reference": "a0eeab580cbdf4414fef6978732510a36ed0a9d6", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", "shasum": "" }, "require": { - "php": ">=7.1" + "php": "^7.2 || ^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.x-dev" + "dev-2.x": "2.x-dev" } }, "autoload": { @@ -1211,27 +1301,28 @@ ], "support": { "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", - "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/master" + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" }, - "time": "2021-06-25T13:47:51+00:00" + "time": "2020-06-27T09:03:43+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "dev-master", + "version": "5.4.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "0b48e261e0a7bcbf1bd118ffd08e52ea6cfd34af" + "reference": "9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/0b48e261e0a7bcbf1bd118ffd08e52ea6cfd34af", - "reference": "0b48e261e0a7bcbf1bd118ffd08e52ea6cfd34af", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c", + "reference": "9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c", "shasum": "" }, "require": { + "doctrine/deprecations": "^1.1", "ext-filter": "*", - "php": "^7.2 || ^8.0", + "php": "^7.4 || ^8.0", "phpdocumentor/reflection-common": "^2.2", "phpdocumentor/type-resolver": "^1.7", "phpstan/phpdoc-parser": "^1.7", @@ -1244,9 +1335,8 @@ "phpstan/phpstan-mockery": "^1.1", "phpstan/phpstan-webmozart-assert": "^1.2", "phpunit/phpunit": "^9.5", - "vimeo/psalm": "^4.26" + "vimeo/psalm": "^5.13" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -1275,13 +1365,13 @@ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.4.1" }, - "time": "2024-01-26T20:33:24+00:00" + "time": "2024-05-21T05:55:05+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "1.x-dev", + "version": "1.8.2", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", @@ -1309,7 +1399,6 @@ "rector/rector": "^0.13.9", "vimeo/psalm": "^4.25" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -1340,16 +1429,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.26.0", + "version": "1.29.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "231e3186624c03d7e7c890ec662b81e6b0405227" + "reference": "fcaefacf2d5c417e928405b71b400d4ce10daaf4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/231e3186624c03d7e7c890ec662b81e6b0405227", - "reference": "231e3186624c03d7e7c890ec662b81e6b0405227", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/fcaefacf2d5c417e928405b71b400d4ce10daaf4", + "reference": "fcaefacf2d5c417e928405b71b400d4ce10daaf4", "shasum": "" }, "require": { @@ -1381,13 +1470,13 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.26.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.29.1" }, - "time": "2024-02-23T16:05:55+00:00" + "time": "2024-05-31T08:52:43+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.x-dev", + "version": "9.2.31", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", @@ -1465,16 +1554,16 @@ }, { "name": "phpunit/php-file-iterator", - "version": "3.0.x-dev", + "version": "3.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "38b24367e1b340aa78b96d7cab042942d917bb84" + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/38b24367e1b340aa78b96d7cab042942d917bb84", - "reference": "38b24367e1b340aa78b96d7cab042942d917bb84", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", "shasum": "" }, "require": { @@ -1513,7 +1602,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0" + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" }, "funding": [ { @@ -1521,7 +1610,7 @@ "type": "github" } ], - "time": "2022-02-11T16:23:04+00:00" + "time": "2021-12-02T12:48:52+00:00" }, { "name": "phpunit/php-invoker", @@ -1706,45 +1795,45 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.x-dev", + "version": "9.6.20", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "5b92d2809fe6c9dbf892e8016df656f16ef157e1" + "reference": "49d7820565836236411f5dc002d16dd689cde42f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5b92d2809fe6c9dbf892e8016df656f16ef157e1", - "reference": "5b92d2809fe6c9dbf892e8016df656f16ef157e1", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/49d7820565836236411f5dc002d16dd689cde42f", + "reference": "49d7820565836236411f5dc002d16dd689cde42f", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.3.1 || ^2", + "doctrine/instantiator": "^1.5.0 || ^2", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.10.1", - "phar-io/manifest": "^2.0.3", - "phar-io/version": "^3.0.2", + "myclabs/deep-copy": "^1.12.0", + "phar-io/manifest": "^2.0.4", + "phar-io/version": "^3.2.1", "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.28", - "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-code-coverage": "^9.2.31", + "phpunit/php-file-iterator": "^3.0.6", "phpunit/php-invoker": "^3.1.1", - "phpunit/php-text-template": "^2.0.3", - "phpunit/php-timer": "^5.0.2", - "sebastian/cli-parser": "^1.0.1", - "sebastian/code-unit": "^1.0.6", + "phpunit/php-text-template": "^2.0.4", + "phpunit/php-timer": "^5.0.3", + "sebastian/cli-parser": "^1.0.2", + "sebastian/code-unit": "^1.0.8", "sebastian/comparator": "^4.0.8", - "sebastian/diff": "^4.0.3", - "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.5", - "sebastian/global-state": "^5.0.1", - "sebastian/object-enumerator": "^4.0.3", - "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^3.2", + "sebastian/diff": "^4.0.6", + "sebastian/environment": "^5.1.5", + "sebastian/exporter": "^4.0.6", + "sebastian/global-state": "^5.0.7", + "sebastian/object-enumerator": "^4.0.4", + "sebastian/resource-operations": "^3.0.4", + "sebastian/type": "^3.2.1", "sebastian/version": "^3.0.2" }, "suggest": { @@ -1789,7 +1878,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.20" }, "funding": [ { @@ -1805,26 +1894,25 @@ "type": "tidelift" } ], - "time": "2024-03-06T06:47:12+00:00" + "time": "2024-07-10T11:45:39+00:00" }, { "name": "psr/container", - "version": "dev-master", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "707984727bd5b2b670e59559d3ed2500240cf875" + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/707984727bd5b2b670e59559d3ed2500240cf875", - "reference": "707984727bd5b2b670e59559d3ed2500240cf875", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", "shasum": "" }, "require": { "php": ">=7.4.0" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -1857,9 +1945,9 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container" + "source": "https://github.com/php-fig/container/tree/2.0.2" }, - "time": "2023-09-22T11:11:30+00:00" + "time": "2021-11-05T16:47:00+00:00" }, { "name": "psr/log", @@ -1913,7 +2001,7 @@ }, { "name": "sebastian/cli-parser", - "version": "1.0.x-dev", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", @@ -2080,16 +2168,16 @@ }, { "name": "sebastian/comparator", - "version": "4.0.x-dev", + "version": "4.0.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "b247957a1c8dc81a671770f74b479c0a78a818f1" + "reference": "fa0f136dd2334583309d32b62544682ee972b51a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/b247957a1c8dc81a671770f74b479c0a78a818f1", - "reference": "b247957a1c8dc81a671770f74b479c0a78a818f1", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a", + "reference": "fa0f136dd2334583309d32b62544682ee972b51a", "shasum": "" }, "require": { @@ -2142,7 +2230,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/4.0" + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8" }, "funding": [ { @@ -2150,11 +2238,11 @@ "type": "github" } ], - "time": "2022-09-14T12:46:14+00:00" + "time": "2022-09-14T12:41:17+00:00" }, { "name": "sebastian/complexity", - "version": "2.0.x-dev", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", @@ -2211,7 +2299,7 @@ }, { "name": "sebastian/diff", - "version": "4.0.x-dev", + "version": "4.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", @@ -2277,7 +2365,7 @@ }, { "name": "sebastian/environment", - "version": "5.1.x-dev", + "version": "5.1.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", @@ -2328,7 +2416,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/5.1" + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.5" }, "funding": [ { @@ -2340,7 +2428,7 @@ }, { "name": "sebastian/exporter", - "version": "4.0.x-dev", + "version": "4.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", @@ -2417,7 +2505,7 @@ }, { "name": "sebastian/global-state", - "version": "5.0.x-dev", + "version": "5.0.7", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", @@ -2481,7 +2569,7 @@ }, { "name": "sebastian/lines-of-code", - "version": "1.0.x-dev", + "version": "1.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", @@ -2650,7 +2738,7 @@ }, { "name": "sebastian/recursion-context", - "version": "4.0.x-dev", + "version": "4.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", @@ -2713,16 +2801,16 @@ }, { "name": "sebastian/resource-operations", - "version": "dev-main", + "version": "3.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "20bdda85c7c585ab265c0c37ec052a019bae29c4" + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/20bdda85c7c585ab265c0c37ec052a019bae29c4", - "reference": "20bdda85c7c585ab265c0c37ec052a019bae29c4", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e", + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e", "shasum": "" }, "require": { @@ -2731,7 +2819,6 @@ "require-dev": { "phpunit/phpunit": "^9.0" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -2756,7 +2843,7 @@ "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", "support": { - "source": "https://github.com/sebastianbergmann/resource-operations/tree/main" + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.4" }, "funding": [ { @@ -2764,11 +2851,11 @@ "type": "github" } ], - "time": "2023-03-25T08:11:39+00:00" + "time": "2024-03-14T16:00:52+00:00" }, { "name": "sebastian/type", - "version": "3.2.x-dev", + "version": "3.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", @@ -2812,7 +2899,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/3.2" + "source": "https://github.com/sebastianbergmann/type/tree/3.2.1" }, "funding": [ { @@ -2824,7 +2911,7 @@ }, { "name": "sebastian/version", - "version": "3.0.x-dev", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", @@ -2877,16 +2964,16 @@ }, { "name": "symfony/console", - "version": "5.4.x-dev", + "version": "v5.4.42", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "39f75d9d73d0c11952fdcecf4877b4d0f62a8f6e" + "reference": "cef62396a0477e94fc52e87a17c6e5c32e226b7f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/39f75d9d73d0c11952fdcecf4877b4d0f62a8f6e", - "reference": "39f75d9d73d0c11952fdcecf4877b4d0f62a8f6e", + "url": "https://api.github.com/repos/symfony/console/zipball/cef62396a0477e94fc52e87a17c6e5c32e226b7f", + "reference": "cef62396a0477e94fc52e87a17c6e5c32e226b7f", "shasum": "" }, "require": { @@ -2956,7 +3043,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/5.4" + "source": "https://github.com/symfony/console/tree/v5.4.42" }, "funding": [ { @@ -2972,26 +3059,25 @@ "type": "tidelift" } ], - "time": "2024-02-20T16:33:57+00:00" + "time": "2024-07-26T12:21:55+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "dev-main", + "version": "v3.5.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "2c438b99bb2753c1628c1e6f523991edea5b03a4" + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/2c438b99bb2753c1628c1e6f523991edea5b03a4", - "reference": "2c438b99bb2753c1628c1e6f523991edea5b03a4", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", "shasum": "" }, "require": { "php": ">=8.1" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -3024,7 +3110,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/main" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0" }, "funding": [ { @@ -3040,20 +3126,20 @@ "type": "tidelift" } ], - "time": "2024-01-02T14:07:37+00:00" + "time": "2024-04-18T09:32:20+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "1.x-dev", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4" + "reference": "0424dff1c58f028c451efff2045f5d92410bd540" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4", - "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/0424dff1c58f028c451efff2045f5d92410bd540", + "reference": "0424dff1c58f028c451efff2045f5d92410bd540", "shasum": "" }, "require": { @@ -3065,7 +3151,6 @@ "suggest": { "ext-ctype": "For best performance" }, - "default-branch": true, "type": "library", "extra": { "thanks": { @@ -3104,7 +3189,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.30.0" }, "funding": [ { @@ -3120,20 +3205,20 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "1.x-dev", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f" + "reference": "64647a7c30b2283f5d49b874d84a18fc22054b7a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/32a9da87d7b3245e09ac426c83d334ae9f06f80f", - "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/64647a7c30b2283f5d49b874d84a18fc22054b7a", + "reference": "64647a7c30b2283f5d49b874d84a18fc22054b7a", "shasum": "" }, "require": { @@ -3142,7 +3227,6 @@ "suggest": { "ext-intl": "For best performance" }, - "default-branch": true, "type": "library", "extra": { "thanks": { @@ -3183,7 +3267,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.30.0" }, "funding": [ { @@ -3199,20 +3283,20 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "1.x-dev", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "bc45c394692b948b4d383a08d7753968bed9a83d" + "reference": "a95281b0be0d9ab48050ebd988b967875cdb9fdb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/bc45c394692b948b4d383a08d7753968bed9a83d", - "reference": "bc45c394692b948b4d383a08d7753968bed9a83d", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/a95281b0be0d9ab48050ebd988b967875cdb9fdb", + "reference": "a95281b0be0d9ab48050ebd988b967875cdb9fdb", "shasum": "" }, "require": { @@ -3221,7 +3305,6 @@ "suggest": { "ext-intl": "For best performance" }, - "default-branch": true, "type": "library", "extra": { "thanks": { @@ -3265,7 +3348,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.30.0" }, "funding": [ { @@ -3281,20 +3364,20 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "1.x-dev", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" + "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", - "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fd22ab50000ef01661e2a31d850ebaa297f8e03c", + "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c", "shasum": "" }, "require": { @@ -3306,7 +3389,6 @@ "suggest": { "ext-mbstring": "For best performance" }, - "default-branch": true, "type": "library", "extra": { "thanks": { @@ -3346,7 +3428,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.30.0" }, "funding": [ { @@ -3362,26 +3444,25 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-06-19T12:30:46+00:00" }, { "name": "symfony/polyfill-php73", - "version": "1.x-dev", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "21bd091060673a1177ae842c0ef8fe30893114d2" + "reference": "ec444d3f3f6505bb28d11afa41e75faadebc10a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/21bd091060673a1177ae842c0ef8fe30893114d2", - "reference": "21bd091060673a1177ae842c0ef8fe30893114d2", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/ec444d3f3f6505bb28d11afa41e75faadebc10a1", + "reference": "ec444d3f3f6505bb28d11afa41e75faadebc10a1", "shasum": "" }, "require": { "php": ">=7.1" }, - "default-branch": true, "type": "library", "extra": { "thanks": { @@ -3423,7 +3504,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.30.0" }, "funding": [ { @@ -3439,26 +3520,25 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/polyfill-php80", - "version": "1.x-dev", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b" + "reference": "77fa7995ac1b21ab60769b7323d600a991a90433" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", - "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/77fa7995ac1b21ab60769b7323d600a991a90433", + "reference": "77fa7995ac1b21ab60769b7323d600a991a90433", "shasum": "" }, "require": { "php": ">=7.1" }, - "default-branch": true, "type": "library", "extra": { "thanks": { @@ -3504,7 +3584,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.30.0" }, "funding": [ { @@ -3520,30 +3600,30 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/service-contracts", - "version": "dev-main", + "version": "v3.5.0", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "cea2eccfcd27ac3deb252bd67f78b9b8ffc4da84" + "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/cea2eccfcd27ac3deb252bd67f78b9b8ffc4da84", - "reference": "cea2eccfcd27ac3deb252bd67f78b9b8ffc4da84", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", + "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", "shasum": "" }, "require": { "php": ">=8.1", - "psr/container": "^1.1|^2.0" + "psr/container": "^1.1|^2.0", + "symfony/deprecation-contracts": "^2.5|^3" }, "conflict": { "ext-psr": "<1.1|>=2" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -3587,7 +3667,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/main" + "source": "https://github.com/symfony/service-contracts/tree/v3.5.0" }, "funding": [ { @@ -3603,20 +3683,20 @@ "type": "tidelift" } ], - "time": "2024-01-02T14:07:37+00:00" + "time": "2024-04-18T09:32:20+00:00" }, { "name": "symfony/string", - "version": "6.4.x-dev", + "version": "v6.4.10", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "4e465a95bdc32f49cf4c7f07f751b843bbd6dcd9" + "reference": "ccf9b30251719567bfd46494138327522b9a9446" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/4e465a95bdc32f49cf4c7f07f751b843bbd6dcd9", - "reference": "4e465a95bdc32f49cf4c7f07f751b843bbd6dcd9", + "url": "https://api.github.com/repos/symfony/string/zipball/ccf9b30251719567bfd46494138327522b9a9446", + "reference": "ccf9b30251719567bfd46494138327522b9a9446", "shasum": "" }, "require": { @@ -3673,7 +3753,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/6.4" + "source": "https://github.com/symfony/string/tree/v6.4.10" }, "funding": [ { @@ -3689,7 +3769,7 @@ "type": "tidelift" } ], - "time": "2024-02-01T13:16:41+00:00" + "time": "2024-07-22T10:21:14+00:00" }, { "name": "theseer/tokenizer", @@ -3901,7 +3981,7 @@ }, { "name": "webmozart/glob", - "version": "4.8.x-dev", + "version": "4.7.0", "source": { "type": "git", "url": "https://github.com/webmozarts/glob.git", @@ -3950,27 +4030,26 @@ }, { "name": "webmozart/path-util", - "version": "dev-master", + "version": "2.3.0", "source": { "type": "git", "url": "https://github.com/webmozart/path-util.git", - "reference": "6099b5238073f87f246863fd58c2e447acfc0d24" + "reference": "d939f7edc24c9a1bb9c0dee5cb05d8e859490725" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/path-util/zipball/6099b5238073f87f246863fd58c2e447acfc0d24", - "reference": "6099b5238073f87f246863fd58c2e447acfc0d24", + "url": "https://api.github.com/repos/webmozart/path-util/zipball/d939f7edc24c9a1bb9c0dee5cb05d8e859490725", + "reference": "d939f7edc24c9a1bb9c0dee5cb05d8e859490725", "shasum": "" }, "require": { - "php": "^5.3.3|^7.0", + "php": ">=5.3.3", "webmozart/assert": "~1.0" }, "require-dev": { "phpunit/phpunit": "^4.6", "sebastian/version": "^1.0.1" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { @@ -3995,14 +4074,14 @@ "description": "A robust cross-platform utility for normalizing, comparing and modifying file paths.", "support": { "issues": "https://github.com/webmozart/path-util/issues", - "source": "https://github.com/webmozart/path-util/tree/master" + "source": "https://github.com/webmozart/path-util/tree/2.3.0" }, "abandoned": "symfony/filesystem", - "time": "2021-11-08T08:17:20+00:00" + "time": "2015-12-17T08:42:14+00:00" } ], "aliases": [], - "minimum-stability": "dev", + "minimum-stability": "RC", "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, From 43090a9c804c025c3b3885f08618172e10bcec5f Mon Sep 17 00:00:00 2001 From: fogelito Date: Tue, 3 Sep 2024 12:08:22 +0300 Subject: [PATCH 101/117] Fix scandir --- src/Storage/Device/Local.php | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index 13bed91a..ed73b218 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -364,15 +364,13 @@ public function deletePath(string $path): bool foreach ($files as $file) { if (is_dir($file)) { - $this->deletePath(\ltrim($file, $this->getRoot().DIRECTORY_SEPARATOR)); + $this->deletePath(substr_replace($file, '', 0, strlen($this->getRoot()))); } else { $this->delete($file, true); } } - \rmdir($path); - - return true; + return \rmdir($path); } /** @@ -517,18 +515,11 @@ public function getPartitionTotalSpace(): float */ public function getFiles(string $dir, int $max = self::MAX_PAGE_SIZE, string $continuationToken = ''): array { - if (! (\str_ends_with($dir, DIRECTORY_SEPARATOR))) { - $dir .= DIRECTORY_SEPARATOR; - } - + $dir = rtrim($dir, DIRECTORY_SEPARATOR); $files = []; - foreach (\scandir($dir) as $file) { - if ($file === '.' || $file === '..') { - continue; - } - - $files[] = $dir.$file; + foreach (\glob($dir.'/*') as $file) { + $files[] = $file; } return $files; From 2119125381f2fed6e16fa4676621b3df0d805031 Mon Sep 17 00:00:00 2001 From: fogelito Date: Tue, 3 Sep 2024 12:18:50 +0300 Subject: [PATCH 102/117] use DIRECTORY_SEPARATOR --- src/Storage/Device/Local.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index ed73b218..3f6e1596 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -518,7 +518,7 @@ public function getFiles(string $dir, int $max = self::MAX_PAGE_SIZE, string $co $dir = rtrim($dir, DIRECTORY_SEPARATOR); $files = []; - foreach (\glob($dir.'/*') as $file) { + foreach (\glob($dir.DIRECTORY_SEPARATOR.'*') as $file) { $files[] = $file; } From 272eb4538615e2a9918619c4b788fb9a258f6f07 Mon Sep 17 00:00:00 2001 From: fogelito Date: Tue, 3 Sep 2024 14:10:31 +0300 Subject: [PATCH 103/117] tests --- src/Storage/Device/Local.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index 3f6e1596..2045cc18 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -364,6 +364,7 @@ public function deletePath(string $path): bool foreach ($files as $file) { if (is_dir($file)) { + //$this->deletePath(\ltrim($file, $this->getRoot().DIRECTORY_SEPARATOR)); $this->deletePath(substr_replace($file, '', 0, strlen($this->getRoot()))); } else { $this->delete($file, true); From 8d74182488562c62f1556863b0b1e7baad429470 Mon Sep 17 00:00:00 2001 From: fogelito Date: Tue, 3 Sep 2024 17:36:26 +0300 Subject: [PATCH 104/117] Add hidden files --- src/Storage/Device/Local.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index 2045cc18..80d49d8c 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -364,7 +364,6 @@ public function deletePath(string $path): bool foreach ($files as $file) { if (is_dir($file)) { - //$this->deletePath(\ltrim($file, $this->getRoot().DIRECTORY_SEPARATOR)); $this->deletePath(substr_replace($file, '', 0, strlen($this->getRoot()))); } else { $this->delete($file, true); @@ -523,6 +522,10 @@ public function getFiles(string $dir, int $max = self::MAX_PAGE_SIZE, string $co $files[] = $file; } + foreach (\glob($dir.DIRECTORY_SEPARATOR.'.[!.]*') as $file) { + $files[] = $file; + } + return $files; } } From 179123e09cfd2922c23f0cff1d05a883fd635d23 Mon Sep 17 00:00:00 2001 From: fogelito Date: Tue, 3 Sep 2024 17:53:44 +0300 Subject: [PATCH 105/117] Add comment --- src/Storage/Device/Local.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index 80d49d8c..e9319db4 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -522,6 +522,9 @@ public function getFiles(string $dir, int $max = self::MAX_PAGE_SIZE, string $co $files[] = $file; } + /** + * Hidden files + */ foreach (\glob($dir.DIRECTORY_SEPARATOR.'.[!.]*') as $file) { $files[] = $file; } From b60be790ef3793190165934f44c07dfa4e5cad81 Mon Sep 17 00:00:00 2001 From: Shmuel Fogel Date: Wed, 4 Sep 2024 11:22:54 +0300 Subject: [PATCH 106/117] Update src/Storage/Device/Local.php Co-authored-by: Jake Barnby --- src/Storage/Device/Local.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index e9319db4..86729863 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -364,7 +364,7 @@ public function deletePath(string $path): bool foreach ($files as $file) { if (is_dir($file)) { - $this->deletePath(substr_replace($file, '', 0, strlen($this->getRoot()))); + $this->deletePath(\substr_replace($file, '', 0, \strlen($this->getRoot() . DIRECTORY_SEPARATOR))); } else { $this->delete($file, true); } From 68aec328c3b0520d0981a583ed363a4d1790a084 Mon Sep 17 00:00:00 2001 From: fogelito Date: Wed, 4 Sep 2024 11:24:04 +0300 Subject: [PATCH 107/117] Linter --- src/Storage/Device/Local.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index 86729863..6819bf7f 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -364,7 +364,7 @@ public function deletePath(string $path): bool foreach ($files as $file) { if (is_dir($file)) { - $this->deletePath(\substr_replace($file, '', 0, \strlen($this->getRoot() . DIRECTORY_SEPARATOR))); + $this->deletePath(\substr_replace($file, '', 0, \strlen($this->getRoot().DIRECTORY_SEPARATOR))); } else { $this->delete($file, true); } From 5acccdb7d98af3d2de471b36a79cc95a82eb81f2 Mon Sep 17 00:00:00 2001 From: Binyamin Yawitz <316103+byawitz@users.noreply.github.com> Date: Thu, 5 Sep 2024 12:40:49 -0400 Subject: [PATCH 108/117] chore: updating versions --- composer.json | 4 +-- composer.lock | 88 +++++++++++++++++++++++++-------------------------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/composer.json b/composer.json index 540f1f78..b610b26b 100644 --- a/composer.json +++ b/composer.json @@ -25,12 +25,12 @@ "ext-snappy": "*", "php": ">=8.0", "utopia-php/framework": "1.0.*", - "utopia-php/system": "0.*.*" + "utopia-php/system": "0.8.*" }, "require-dev": { "phpunit/phpunit": "^9.3", "vimeo/psalm": "4.0.1", "laravel/pint": "1.2.*" }, - "minimum-stability": "RC" + "minimum-stability": "stable" } diff --git a/composer.lock b/composer.lock index be75e48b..f87ade2b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cf7e55fc0344e71e130f62fdd788835b", + "content-hash": "c71b86be6958247ecbd5722ac24750e9", "packages": [ { "name": "utopia-php/di", @@ -56,22 +56,22 @@ }, { "name": "utopia-php/framework", - "version": "1.0.0-RC2", + "version": "1.0.0", "source": { "type": "git", "url": "https://github.com/utopia-php/http.git", - "reference": "d1e9674dbf33bed03fa53854ec1f2c6e074cf4d7" + "reference": "cc880ec41f7f163d4f9956fec26cc6be51b412cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/d1e9674dbf33bed03fa53854ec1f2c6e074cf4d7", - "reference": "d1e9674dbf33bed03fa53854ec1f2c6e074cf4d7", + "url": "https://api.github.com/repos/utopia-php/http/zipball/cc880ec41f7f163d4f9956fec26cc6be51b412cf", + "reference": "cc880ec41f7f163d4f9956fec26cc6be51b412cf", "shasum": "" }, "require": { "ext-swoole": "*", "php": ">=8.0", - "utopia-php/servers": "0.1.* " + "utopia-php/servers": "0.1.*" }, "require-dev": { "ext-xdebug": "*", @@ -100,9 +100,9 @@ ], "support": { "issues": "https://github.com/utopia-php/http/issues", - "source": "https://github.com/utopia-php/http/tree/1.0.0-RC2" + "source": "https://github.com/utopia-php/http/tree/1.0.0" }, - "time": "2024-08-08T14:46:41+00:00" + "time": "2024-09-05T15:38:08+00:00" }, { "name": "utopia-php/servers", @@ -1429,16 +1429,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.29.1", + "version": "1.30.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "fcaefacf2d5c417e928405b71b400d4ce10daaf4" + "reference": "5ceb0e384997db59f38774bf79c2a6134252c08f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/fcaefacf2d5c417e928405b71b400d4ce10daaf4", - "reference": "fcaefacf2d5c417e928405b71b400d4ce10daaf4", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/5ceb0e384997db59f38774bf79c2a6134252c08f", + "reference": "5ceb0e384997db59f38774bf79c2a6134252c08f", "shasum": "" }, "require": { @@ -1470,41 +1470,41 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.29.1" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.30.0" }, - "time": "2024-05-31T08:52:43+00:00" + "time": "2024-08-29T09:54:52+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.31", + "version": "9.2.32", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965" + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/48c34b5d8d983006bd2adc2d0de92963b9155965", - "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/85402a822d1ecf1db1096959413d35e1c37cf1a5", + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.18 || ^5.0", + "nikic/php-parser": "^4.19.1 || ^5.1.0", "php": ">=7.3", - "phpunit/php-file-iterator": "^3.0.3", - "phpunit/php-text-template": "^2.0.2", - "sebastian/code-unit-reverse-lookup": "^2.0.2", - "sebastian/complexity": "^2.0", - "sebastian/environment": "^5.1.2", - "sebastian/lines-of-code": "^1.0.3", - "sebastian/version": "^3.0.1", - "theseer/tokenizer": "^1.2.0" + "phpunit/php-file-iterator": "^3.0.6", + "phpunit/php-text-template": "^2.0.4", + "sebastian/code-unit-reverse-lookup": "^2.0.3", + "sebastian/complexity": "^2.0.3", + "sebastian/environment": "^5.1.5", + "sebastian/lines-of-code": "^1.0.4", + "sebastian/version": "^3.0.2", + "theseer/tokenizer": "^1.2.3" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^9.6" }, "suggest": { "ext-pcov": "PHP extension that provides line coverage", @@ -1513,7 +1513,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "9.2-dev" + "dev-main": "9.2.x-dev" } }, "autoload": { @@ -1542,7 +1542,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.31" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.32" }, "funding": [ { @@ -1550,7 +1550,7 @@ "type": "github" } ], - "time": "2024-03-02T06:37:42+00:00" + "time": "2024-08-22T04:23:01+00:00" }, { "name": "phpunit/php-file-iterator", @@ -2964,16 +2964,16 @@ }, { "name": "symfony/console", - "version": "v5.4.42", + "version": "v5.4.43", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "cef62396a0477e94fc52e87a17c6e5c32e226b7f" + "reference": "e86f8554de667c16dde8aeb89a3990cfde924df9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/cef62396a0477e94fc52e87a17c6e5c32e226b7f", - "reference": "cef62396a0477e94fc52e87a17c6e5c32e226b7f", + "url": "https://api.github.com/repos/symfony/console/zipball/e86f8554de667c16dde8aeb89a3990cfde924df9", + "reference": "e86f8554de667c16dde8aeb89a3990cfde924df9", "shasum": "" }, "require": { @@ -3043,7 +3043,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.42" + "source": "https://github.com/symfony/console/tree/v5.4.43" }, "funding": [ { @@ -3059,7 +3059,7 @@ "type": "tidelift" } ], - "time": "2024-07-26T12:21:55+00:00" + "time": "2024-08-13T16:31:56+00:00" }, { "name": "symfony/deprecation-contracts", @@ -3687,16 +3687,16 @@ }, { "name": "symfony/string", - "version": "v6.4.10", + "version": "v6.4.11", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "ccf9b30251719567bfd46494138327522b9a9446" + "reference": "5bc3eb632cf9c8dbfd6529d89be9950d1518883b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/ccf9b30251719567bfd46494138327522b9a9446", - "reference": "ccf9b30251719567bfd46494138327522b9a9446", + "url": "https://api.github.com/repos/symfony/string/zipball/5bc3eb632cf9c8dbfd6529d89be9950d1518883b", + "reference": "5bc3eb632cf9c8dbfd6529d89be9950d1518883b", "shasum": "" }, "require": { @@ -3753,7 +3753,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.4.10" + "source": "https://github.com/symfony/string/tree/v6.4.11" }, "funding": [ { @@ -3769,7 +3769,7 @@ "type": "tidelift" } ], - "time": "2024-07-22T10:21:14+00:00" + "time": "2024-08-12T09:55:28+00:00" }, { "name": "theseer/tokenizer", @@ -4081,7 +4081,7 @@ } ], "aliases": [], - "minimum-stability": "RC", + "minimum-stability": "stable", "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, From b2f18c666ece575c87d6f5f806bb91f138c5cc7a Mon Sep 17 00:00:00 2001 From: Fabian Gruber Date: Wed, 9 Oct 2024 17:01:08 +0200 Subject: [PATCH 109/117] chore: update utopia-php/system to 0.9.0 --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index b610b26b..5d588d68 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "ext-snappy": "*", "php": ">=8.0", "utopia-php/framework": "1.0.*", - "utopia-php/system": "0.8.*" + "utopia-php/system": "0.9.*" }, "require-dev": { "phpunit/phpunit": "^9.3", diff --git a/composer.lock b/composer.lock index f87ade2b..55f87358 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c71b86be6958247ecbd5722ac24750e9", + "content-hash": "7b6b27dd419e73452c225a74f0de6a0c", "packages": [ { "name": "utopia-php/di", @@ -159,16 +159,16 @@ }, { "name": "utopia-php/system", - "version": "0.8.0", + "version": "0.9.0", "source": { "type": "git", "url": "https://github.com/utopia-php/system.git", - "reference": "a2cbfb3c69b9ecb8b6f06c5774f3cf279ea7665e" + "reference": "8e4a7edaf2dfeb4c9524e9f766d27754f2c4b64d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/system/zipball/a2cbfb3c69b9ecb8b6f06c5774f3cf279ea7665e", - "reference": "a2cbfb3c69b9ecb8b6f06c5774f3cf279ea7665e", + "url": "https://api.github.com/repos/utopia-php/system/zipball/8e4a7edaf2dfeb4c9524e9f766d27754f2c4b64d", + "reference": "8e4a7edaf2dfeb4c9524e9f766d27754f2c4b64d", "shasum": "" }, "require": { @@ -209,9 +209,9 @@ ], "support": { "issues": "https://github.com/utopia-php/system/issues", - "source": "https://github.com/utopia-php/system/tree/0.8.0" + "source": "https://github.com/utopia-php/system/tree/0.9.0" }, - "time": "2024-04-01T10:22:28+00:00" + "time": "2024-10-09T14:44:01+00:00" } ], "packages-dev": [ From 7eb441939d3d94ff722a58d7607acf730f441878 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 6 Nov 2024 08:53:42 +0000 Subject: [PATCH 110/117] retry with delay in s3 adapter --- src/Storage/Device/S3.php | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index c319bc57..7d4deafb 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -102,6 +102,10 @@ class S3 extends Device protected const MAX_PAGE_SIZE = 1000; + protected static int $retryAttempts = 5; + + protected static int $retryDelay = 2; // seconds + /** * @var string */ @@ -242,6 +246,28 @@ public function setHttpVersion(?int $httpVersion): self return $this; } + /** + * Set retry attempts + * + * @param int $attempts + * @return void + */ + public static function setRetryAttempts(int $attempts) + { + self::$retryAttempts = $attempts; + } + + /** + * Set retry delay in seconds + * + * @param int $delay + * @return void + */ + public static function setRetryDelay(int $delay): void + { + self::$retryDelay = $delay; + } + /** * Upload. * @@ -915,11 +941,20 @@ protected function call(string $method, string $uri, string $data = '', array $p $result = \curl_exec($curl); + $response->code = \curl_getinfo($curl, CURLINFO_HTTP_CODE); + + $attempt = 0; + while ($attempt < self::$retryAttempts && $response->code === 503) { + sleep(self::$retryDelay); + $attempt++; + $result = \curl_exec($curl); + $response->code = \curl_getinfo($curl, CURLINFO_HTTP_CODE); + } + if (! $result) { throw new Exception(\curl_error($curl)); } - $response->code = \curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($response->code >= 400) { throw new Exception($response->body, $response->code); } From fce7a27c2dd472bd7466ff4a2822505e2b1a9f6e Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 6 Nov 2024 09:13:25 +0000 Subject: [PATCH 111/117] use ms --- src/Storage/Device/S3.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 7d4deafb..9805d685 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -104,7 +104,7 @@ class S3 extends Device protected static int $retryAttempts = 5; - protected static int $retryDelay = 2; // seconds + protected static int $retryDelay = 100; // milliseconds /** * @var string @@ -258,7 +258,7 @@ public static function setRetryAttempts(int $attempts) } /** - * Set retry delay in seconds + * Set retry delay in milliseconds * * @param int $delay * @return void @@ -945,7 +945,7 @@ protected function call(string $method, string $uri, string $data = '', array $p $attempt = 0; while ($attempt < self::$retryAttempts && $response->code === 503) { - sleep(self::$retryDelay); + usleep(self::$retryDelay); $attempt++; $result = \curl_exec($curl); $response->code = \curl_getinfo($curl, CURLINFO_HTTP_CODE); From baad5074d8bf3d83abdf4b1465fec3d8d38d091a Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 6 Nov 2024 09:19:24 +0000 Subject: [PATCH 112/117] tweak defaults --- src/Storage/Device/S3.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 9805d685..77dd26b9 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -102,9 +102,9 @@ class S3 extends Device protected const MAX_PAGE_SIZE = 1000; - protected static int $retryAttempts = 5; + protected static int $retryAttempts = 3; - protected static int $retryDelay = 100; // milliseconds + protected static int $retryDelay = 500; // milliseconds /** * @var string From eb932aabb8060a7dbcb97cc4b04399c7e5ee6f88 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 6 Nov 2024 09:31:47 +0000 Subject: [PATCH 113/117] fix delay --- src/Storage/Device/S3.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 77dd26b9..7a9bfbb1 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -945,7 +945,7 @@ protected function call(string $method, string $uri, string $data = '', array $p $attempt = 0; while ($attempt < self::$retryAttempts && $response->code === 503) { - usleep(self::$retryDelay); + usleep(self::$retryDelay * 1000); $attempt++; $result = \curl_exec($curl); $response->code = \curl_getinfo($curl, CURLINFO_HTTP_CODE); From 30326d7e8c6119d5f43607949a9082991b7f2fbb Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 24 Nov 2024 02:26:14 +0000 Subject: [PATCH 114/117] Fix: failed upload retry with test --- src/Storage/Device/Local.php | 12 +++-- src/Storage/Device/S3.php | 7 ++- tests/Storage/Device/LocalTest.php | 54 +++++++++++++++++++++++ tests/Storage/S3Base.php | 71 ++++++++++++++++++++++++++++++ 4 files changed, 140 insertions(+), 4 deletions(-) diff --git a/src/Storage/Device/Local.php b/src/Storage/Device/Local.php index 6819bf7f..a587a7cf 100644 --- a/src/Storage/Device/Local.php +++ b/src/Storage/Device/Local.php @@ -95,8 +95,14 @@ public function upload(string $source, string $path, int $chunk = 1, int $chunks $tmp = \dirname($path).DIRECTORY_SEPARATOR.'tmp_'.\basename($path).DIRECTORY_SEPARATOR.\basename($path).'_chunks.log'; $this->createDirectory(\dirname($tmp)); - if (! file_put_contents($tmp, "$chunk\n", FILE_APPEND)) { - throw new Exception('Can\'t write chunk log '.$tmp); + + $chunkFilePath = dirname($tmp).DIRECTORY_SEPARATOR.pathinfo($path, PATHINFO_FILENAME).'.part.'.$chunk; + + // skip writing chunk if the chunk was re-uploaded + if (! file_exists($chunkFilePath)) { + if (! file_put_contents($tmp, "$chunk\n", FILE_APPEND)) { + throw new Exception('Can\'t write chunk log '.$tmp); + } } $chunkLogs = file($tmp); @@ -106,7 +112,7 @@ public function upload(string $source, string $path, int $chunk = 1, int $chunks $chunksReceived = count(file($tmp)); - if (! \rename($source, dirname($tmp).DIRECTORY_SEPARATOR.pathinfo($path, PATHINFO_FILENAME).'.part.'.$chunk)) { + if (! \rename($source, $chunkFilePath)) { throw new Exception('Failed to write chunk '.$chunk); } diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 7a9bfbb1..557446fa 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -318,8 +318,13 @@ public function uploadData(string $data, string $path, string $contentType, int $etag = $this->uploadPart($data, $path, $contentType, $chunk, $uploadId); $metadata['parts'] ??= []; $metadata['parts'][] = ['partNumber' => $chunk, 'etag' => $etag]; + $metadata['chunksUploaded'] ??= []; + $metadata['chunksUploaded'][$chunk] = 1; $metadata['chunks'] ??= 0; - $metadata['chunks']++; + // skip incrementing if the chunk was re-uploaded + if (! array_key_exists($chunk, $metadata['chunksUploaded'])) { + $metadata['chunks']++; + } if ($metadata['chunks'] == $chunks) { $this->completeMultipartUpload($path, $uploadId, $metadata['parts']); } diff --git a/tests/Storage/Device/LocalTest.php b/tests/Storage/Device/LocalTest.php index a2156b6a..c3d91b23 100644 --- a/tests/Storage/Device/LocalTest.php +++ b/tests/Storage/Device/LocalTest.php @@ -173,6 +173,60 @@ public function testPartUpload() return $dest; } + public function testPartUploadRetry() + { + $source = __DIR__.'/../../resources/disk-a/large_file.mp4'; + $dest = $this->object->getPath('uploaded2.mp4'); + $totalSize = \filesize($source); + // AWS S3 requires each part to be at least 5MB except for last part + $chunkSize = 5 * 1024 * 1024; + + $chunks = ceil($totalSize / $chunkSize); + + $chunk = 1; + $start = 0; + $handle = @fopen($source, 'rb'); + $op = __DIR__.'/chunkx.part'; + while ($start < $totalSize) { + $contents = fread($handle, $chunkSize); + $op = __DIR__.'/chunkx.part'; + $cc = fopen($op, 'wb'); + fwrite($cc, $contents); + fclose($cc); + $this->object->upload($op, $dest, $chunk, $chunks); + $start += strlen($contents); + $chunk++; + if ($chunk == 2) { + break; + } + fseek($handle, $start); + } + @fclose($handle); + + $chunk = 1; + $start = 0; + // retry from first to make sure duplicate chunk re-upload works without issue + $handle = @fopen($source, 'rb'); + $op = __DIR__.'/chunkx.part'; + while ($start < $totalSize) { + $contents = fread($handle, $chunkSize); + $op = __DIR__.'/chunkx.part'; + $cc = fopen($op, 'wb'); + fwrite($cc, $contents); + fclose($cc); + $this->object->upload($op, $dest, $chunk, $chunks); + $start += strlen($contents); + $chunk++; + fseek($handle, $start); + } + @fclose($handle); + + $this->assertEquals(\filesize($source), $this->object->getFileSize($dest)); + $this->assertEquals(\md5_file($source), $this->object->getFileHash($dest)); + + return $dest; + } + public function testAbort() { $source = __DIR__.'/../../resources/disk-a/large_file.mp4'; diff --git a/tests/Storage/S3Base.php b/tests/Storage/S3Base.php index 00a60f52..7bf47c53 100644 --- a/tests/Storage/S3Base.php +++ b/tests/Storage/S3Base.php @@ -295,6 +295,77 @@ public function testPartUpload() return $dest; } + public function testPartUploadRetry() + { + $source = __DIR__.'/../resources/disk-a/large_file.mp4'; + $dest = $this->object->getPath('uploaded.mp4'); + $totalSize = \filesize($source); + // AWS S3 requires each part to be at least 5MB except for last part + $chunkSize = 5 * 1024 * 1024; + + $chunks = ceil($totalSize / $chunkSize); + + $chunk = 1; + $start = 0; + + $metadata = [ + 'parts' => [], + 'chunks' => 0, + 'uploadId' => null, + 'content_type' => \mime_content_type($source), + ]; + $handle = @fopen($source, 'rb'); + $op = __DIR__.'/chunk.part'; + while ($start < $totalSize) { + $contents = fread($handle, $chunkSize); + $op = __DIR__.'/chunk.part'; + $cc = fopen($op, 'wb'); + fwrite($cc, $contents); + fclose($cc); + $etag = $this->object->upload($op, $dest, $chunk, $chunks, $metadata); + $parts[] = ['partNumber' => $chunk, 'etag' => $etag]; + $start += strlen($contents); + $chunk++; + if ($chunk == 2) { + break; + } + fseek($handle, $start); + } + @fclose($handle); + unlink($op); + + $chunk = 1; + $start = 0; + // retry from first to make sure duplicate chunk re-upload works without issue + $handle = @fopen($source, 'rb'); + $op = __DIR__.'/chunk.part'; + while ($start < $totalSize) { + $contents = fread($handle, $chunkSize); + $op = __DIR__.'/chunk.part'; + $cc = fopen($op, 'wb'); + fwrite($cc, $contents); + fclose($cc); + $etag = $this->object->upload($op, $dest, $chunk, $chunks, $metadata); + $parts[] = ['partNumber' => $chunk, 'etag' => $etag]; + $start += strlen($contents); + $chunk++; + fseek($handle, $start); + } + @fclose($handle); + unlink($op); + + $this->assertEquals(\filesize($source), $this->object->getFileSize($dest)); + + // S3 doesnt provide a method to get a proper MD5-hash of a file created using multipart upload + // https://stackoverflow.com/questions/8618218/amazon-s3-checksum + // More info on how AWS calculates ETag for multipart upload here + // https://savjee.be/2015/10/Verifying-Amazon-S3-multi-part-uploads-with-ETag-hash/ + // TODO + // $this->assertEquals(\md5_file($source), $this->object->getFileHash($dest)); + // $this->object->delete($dest); + return $dest; + } + /** * @depends testPartUpload */ From 39cf3e8393dcad4a0b35153d0f1696e0fb6e19d3 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 25 Nov 2024 07:39:53 +0000 Subject: [PATCH 115/117] fix s3 chunk upload --- src/Storage/Device/S3.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 557446fa..70611612 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -319,10 +319,10 @@ public function uploadData(string $data, string $path, string $contentType, int $metadata['parts'] ??= []; $metadata['parts'][] = ['partNumber' => $chunk, 'etag' => $etag]; $metadata['chunksUploaded'] ??= []; - $metadata['chunksUploaded'][$chunk] = 1; $metadata['chunks'] ??= 0; // skip incrementing if the chunk was re-uploaded if (! array_key_exists($chunk, $metadata['chunksUploaded'])) { + $metadata['chunksUploaded'][$chunk] = true; $metadata['chunks']++; } if ($metadata['chunks'] == $chunks) { From 93ce8a418b4b5461ad5b170d07c8b5e9c52a119c Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 25 Nov 2024 08:48:27 +0000 Subject: [PATCH 116/117] refactor s3 chunked upload --- src/Storage/Device/S3.php | 6 +++--- tests/Storage/S3Base.php | 9 +++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 70611612..26b7b7fb 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -317,7 +317,7 @@ public function uploadData(string $data, string $path, string $contentType, int $etag = $this->uploadPart($data, $path, $contentType, $chunk, $uploadId); $metadata['parts'] ??= []; - $metadata['parts'][] = ['partNumber' => $chunk, 'etag' => $etag]; + $metadata['parts'][$chunk] = $etag; $metadata['chunksUploaded'] ??= []; $metadata['chunks'] ??= 0; // skip incrementing if the chunk was re-uploaded @@ -435,8 +435,8 @@ protected function completeMultipartUpload(string $path, string $uploadId, array $uri = $path !== '' ? '/'.\str_replace(['%2F', '%3F'], ['/', '?'], \rawurlencode($path)) : '/'; $body = ''; - foreach ($parts as $part) { - $body .= "{$part['etag']}{$part['partNumber']}"; + foreach ($parts as $key => $etag) { + $body .= "{$etag}{$key}"; } $body .= ''; diff --git a/tests/Storage/S3Base.php b/tests/Storage/S3Base.php index 7bf47c53..314cfe02 100644 --- a/tests/Storage/S3Base.php +++ b/tests/Storage/S3Base.php @@ -274,8 +274,7 @@ public function testPartUpload() $cc = fopen($op, 'wb'); fwrite($cc, $contents); fclose($cc); - $etag = $this->object->upload($op, $dest, $chunk, $chunks, $metadata); - $parts[] = ['partNumber' => $chunk, 'etag' => $etag]; + $this->object->upload($op, $dest, $chunk, $chunks, $metadata); $start += strlen($contents); $chunk++; fseek($handle, $start); @@ -322,8 +321,7 @@ public function testPartUploadRetry() $cc = fopen($op, 'wb'); fwrite($cc, $contents); fclose($cc); - $etag = $this->object->upload($op, $dest, $chunk, $chunks, $metadata); - $parts[] = ['partNumber' => $chunk, 'etag' => $etag]; + $this->object->upload($op, $dest, $chunk, $chunks, $metadata); $start += strlen($contents); $chunk++; if ($chunk == 2) { @@ -345,8 +343,7 @@ public function testPartUploadRetry() $cc = fopen($op, 'wb'); fwrite($cc, $contents); fclose($cc); - $etag = $this->object->upload($op, $dest, $chunk, $chunks, $metadata); - $parts[] = ['partNumber' => $chunk, 'etag' => $etag]; + $this->object->upload($op, $dest, $chunk, $chunks, $metadata); $start += strlen($contents); $chunk++; fseek($handle, $start); From 9877787be3f82afb0685108c0294e081927b1446 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 28 Nov 2024 00:51:32 +0000 Subject: [PATCH 117/117] cleanup --- src/Storage/Device/S3.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Storage/Device/S3.php b/src/Storage/Device/S3.php index 26b7b7fb..c21bb9cb 100644 --- a/src/Storage/Device/S3.php +++ b/src/Storage/Device/S3.php @@ -315,16 +315,15 @@ public function uploadData(string $data, string $path, string $contentType, int $metadata['uploadId'] = $uploadId; } - $etag = $this->uploadPart($data, $path, $contentType, $chunk, $uploadId); $metadata['parts'] ??= []; - $metadata['parts'][$chunk] = $etag; - $metadata['chunksUploaded'] ??= []; $metadata['chunks'] ??= 0; + + $etag = $this->uploadPart($data, $path, $contentType, $chunk, $uploadId); // skip incrementing if the chunk was re-uploaded - if (! array_key_exists($chunk, $metadata['chunksUploaded'])) { - $metadata['chunksUploaded'][$chunk] = true; + if (! array_key_exists($chunk, $metadata['parts'])) { $metadata['chunks']++; } + $metadata['parts'][$chunk] = $etag; if ($metadata['chunks'] == $chunks) { $this->completeMultipartUpload($path, $uploadId, $metadata['parts']); }