diff --git a/src/Flysystem/StreamCommand/StreamStatCommand.php b/src/Flysystem/StreamCommand/StreamStatCommand.php index 4ea23ae..c6041f6 100644 --- a/src/Flysystem/StreamCommand/StreamStatCommand.php +++ b/src/Flysystem/StreamCommand/StreamStatCommand.php @@ -142,6 +142,8 @@ public static function getRemoteStats(FileData $current): array [$mode, $size, $lastModified] = self::getRemoteDirectoryStats($current, $converter, $visibility); } elseif ($current->filesystem->fileExists($current->file)) { [$mode, $size, $lastModified] = self::getRemoteFileStats($current, $converter, $visibility); + } else { + throw $e; } } else { throw $e; diff --git a/tests/StreamCommand/StreamStatTest.php b/tests/StreamCommand/StreamStatTest.php index c0048aa..892a922 100644 --- a/tests/StreamCommand/StreamStatTest.php +++ b/tests/StreamCommand/StreamStatTest.php @@ -1,4 +1,5 @@ getCurrent(); + + /** @var MockObject $filesystem */ + $filesystem = $current->filesystem; + $filesystem->method('visibility') + ->with('test') + ->willReturn(Visibility::PUBLIC); + $filesystem->method('lastModified') + ->with('test') + ->willThrowException(UnableToRetrieveMetadata::lastModified(self::TEST_PATH)); + + $this->assertFalse(@StreamStatCommand::run($current)); + + $this->expectErrorWithMessage('Stat failed'); + StreamStatCommand::run($current); + } + public function testRemoteException(): void { $current = $this->getCurrent();