File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -188,7 +188,9 @@ private function createDirectoryRecursively(string $path): bool
188188 $ parentDir = dirname ($ path );
189189
190190 while (!$ this ->isDirectory ($ parentDir )) {
191- $ this ->createDirectoryRecursively ($ parentDir );
191+ if (!$ this ->createDirectoryRecursively ($ parentDir )) {
192+ return false ;
193+ }
192194 }
193195
194196 if (!$ this ->isDirectory ($ path )) {
Original file line number Diff line number Diff line change @@ -497,6 +497,23 @@ public function testCreateDirectory(): void
497497 self ::assertTrue ($ this ->driver ->createDirectory (self ::URL . 'test/test2/ ' ));
498498 }
499499
500+ /**
501+ * This test ensures that the method does not loop infinitely in case of an exception
502+ *
503+ * @return void
504+ * @throws FileSystemException
505+ * @throws \PHPUnit\Framework\MockObject\Exception
506+ */
507+ public function testShouldFailSafelyIfUnableToCreateDirectory (): void
508+ {
509+ $ this ->adapterMock ->expects (self ::once ())
510+ ->method ('createDirectory ' )
511+ ->willThrowException ($ this ->createMock (\League \Flysystem \FilesystemException::class))
512+ ->with ('test ' );
513+
514+ self ::assertFalse ($ this ->driver ->createDirectory (self ::URL . 'test/test2/ ' ));
515+ }
516+
500517 public function testRename (): void
501518 {
502519 $ this ->adapterMock ->expects (self ::once ())
You can’t perform that action at this time.
0 commit comments