diff --git a/README.md b/README.md index 3101d51..b9c7e80 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ For example: virtual path `/Xa3X9GlR6EmbnY1RLVTk5VUtOVkk/0B3X9GlR6EmbnY1RLVTk5VU ## Installation -- For **Flysystem V2** or **Laravel >= 9.x.x** +- For **Flysystem V2/V3** or **Laravel >= 9.x.x** ```bash composer require masbug/flysystem-google-drive-ext diff --git a/composer.json b/composer.json index 897a342..d695e05 100644 --- a/composer.json +++ b/composer.json @@ -23,13 +23,13 @@ "php": "^7.2 | ^8.0", "ext-mbstring": "*", "guzzlehttp/guzzle": "^6.3 | ^7.0", - "league/flysystem": "^2.1.1", + "league/flysystem": "^2.1.1|^3.0", "google/apiclient": "^2.2", "guzzlehttp/psr7": "^1.7|^2.0" }, "require-dev": { "phpunit/phpunit": "^8.0 | ^9.3", - "league/flysystem-adapter-test-utilities": "^2.0" + "league/flysystem-adapter-test-utilities": "^2.0|^3.0" }, "autoload": { "psr-4": { diff --git a/src/GoogleDriveAdapter.php b/src/GoogleDriveAdapter.php index a79e758..e5232ec 100644 --- a/src/GoogleDriveAdapter.php +++ b/src/GoogleDriveAdapter.php @@ -370,6 +370,20 @@ public function fileExists(string $path): bool } } + /** + * @throws FilesystemException + */ + public function directoryExists(string $path): bool + { + try { + $location = $this->prefixer->prefixPath($path); + $this->toVirtualPath($location, true, true); + return true; + } catch (UnableToReadFile $e) { + return false; + } + } + private function writeData(string $location, $contents, Config $config) { $updating = null; @@ -636,6 +650,17 @@ public function createDirectory(string $dirname, Config $config): void throw UnableToCreateDirectory::atLocation($dirname, 'Failed to create dir'); } + /** + * {@inheritdoc} + */ + public function has($path): bool + { + if ($this->useDisplayPaths) { + $this->toVirtualPath($path, false); + } + return ($this->getFileObject($path, true) instanceof DriveFile); + } + /** * {@inheritdoc} */ diff --git a/tests/GoogleDriveAdapterTests.php b/tests/GoogleDriveAdapterTests.php index 053b394..8894962 100644 --- a/tests/GoogleDriveAdapterTests.php +++ b/tests/GoogleDriveAdapterTests.php @@ -10,6 +10,8 @@ class GoogleDriveAdapterTests extends FilesystemAdapterTestCase { + protected $exceptionTypeToRetryOn = null; + /** * @var string */ @@ -20,6 +22,12 @@ public static function setUpBeforeClass(): void static::$adapterPrefix = 'ci/'.bin2hex(random_bytes(10)); } + protected function retryOnException(string $className, int $timout = 2): void + { + $this->exceptionTypeToRetryOn = null; + $this->timeoutForExceptionRetry = $timout; + } + protected static function createFilesystemAdapter(): FilesystemAdapter { $file = __DIR__.'/../google-drive-service-account.json';