Fclose() error when downloading multiple files

Greetings
I’m getting an error when trying to download a folder ; the zip file is empty and the log says:

fclose(): Argument #1 ($stream) must be of type resource, bool given

/var/www/html/lib/private/Streamer.php:138

It correspond to this code:

                                try {
                                        $fh = $file->fopen('r');
                                } catch (NotPermittedException $e) {
                                        continue;
                                }
                                $this->addFileFromStream(
                                        $fh,
                                        $internalDir . $file->getName(),
                                        $file->getSize(),
                                        $file->getMTime()
                                );
                                fclose($fh)

I assume fopen throws an exception which is not handled, but I don’t know which one.

How can I ouput the exception?

After some digging, I found that one of the hundred uploaded files has different permissions:
-rwx------
instead of
-rw-r–r–

All the files where uploaded together, so I don’t know why…

Have you solved the problem?