From 04f047aec618a3aefdedf0d41c46bc66c301f603 Mon Sep 17 00:00:00 2001 From: Aaron Piotrowski Date: Sat, 27 Oct 2018 11:35:33 -0500 Subject: [PATCH] Fix scandir on empty directory in UvDriver --- lib/UvDriver.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/UvDriver.php b/lib/UvDriver.php index 84dcefe..05b6205 100644 --- a/lib/UvDriver.php +++ b/lib/UvDriver.php @@ -453,8 +453,10 @@ class UvDriver implements Driver $this->poll->listen($deferred->promise()); \uv_fs_readdir($this->loop, $path, 0, function ($fh, $data) use ($deferred, $path) { - if (empty($fh)) { + if (empty($fh) && $data !== 0) { $deferred->fail(new FilesystemException("Failed reading contents from {$path}")); + } elseif ($data === 0) { + $deferred->resolve([]); } else { $deferred->resolve($data); }