From 03592e78fe4a0e76bc1e1ad5094d8d1b45d03a36 Mon Sep 17 00:00:00 2001 From: Frank de Jonge Date: Sat, 15 Jan 2022 11:54:12 +0100 Subject: [PATCH] Also delete parent directory in ZipArchive implementation --- src/ZipArchive/ZipArchiveAdapter.php | 3 +-- src/ZipArchive/ZipArchiveAdapterTest.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ZipArchive/ZipArchiveAdapter.php b/src/ZipArchive/ZipArchiveAdapter.php index 58586deea..9d2e29ac1 100644 --- a/src/ZipArchive/ZipArchiveAdapter.php +++ b/src/ZipArchive/ZipArchiveAdapter.php @@ -30,7 +30,6 @@ use function fopen; use function rewind; use function stream_copy_to_stream; -use function stream_with_contents; final class ZipArchiveAdapter implements FilesystemAdapter { @@ -161,7 +160,7 @@ public function deleteDirectory(string $path): void $itemPath = $stats['name']; - if ($prefixedPath === $itemPath || strpos($itemPath, $prefixedPath) !== 0) { + if (strpos($itemPath, $prefixedPath) !== 0) { continue; } diff --git a/src/ZipArchive/ZipArchiveAdapterTest.php b/src/ZipArchive/ZipArchiveAdapterTest.php index 4b64da78f..2dafd550a 100644 --- a/src/ZipArchive/ZipArchiveAdapterTest.php +++ b/src/ZipArchive/ZipArchiveAdapterTest.php @@ -136,7 +136,7 @@ public function deleting_a_directory(): void $this->adapter()->deleteDirectory('one'); $items = iterator_to_array($this->adapter()->listContents('', true)); - $this->assertCount(4, $items); + $this->assertCount(3, $items); } /**