From a93d11b02e186b1de2e12d795387ba4600e85611 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Wed, 18 Dec 2024 15:55:55 +0000 Subject: [PATCH] Fix webhost support --- src/Magic.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Magic.php b/src/Magic.php index 82360ed7d..75a2a6ea1 100644 --- a/src/Magic.php +++ b/src/Magic.php @@ -21,6 +21,9 @@ namespace danog\MadelineProto; use Amp\DeferredFuture; +use Amp\File\Driver\BlockingFilesystemDriver; +use Amp\File\Driver\EioFilesystemDriver; +use Amp\File\Driver\UvFilesystemDriver; use Amp\SignalException; use danog\MadelineProto\TL\Conversion\Extension; use phpseclib3\Math\BigInteger; @@ -36,6 +39,8 @@ use const SIG_DFL; use const SIGINT; use const SIGTERM; + +use function Amp\File\filesystem; use function Amp\Log\hasColorSupport; use function function_exists; @@ -227,6 +232,18 @@ public static function start(bool $light): void \define('AMP_WORKER', 1); } if (!self::$initedLight) { + // Setup file driver + $driver = EventLoop::getDriver(); + + if (UvFilesystemDriver::isSupported($driver)) { + $driver = new UvFilesystemDriver($driver); + } elseif (EioFilesystemDriver::isSupported()) { + $driver = new EioFilesystemDriver($driver); + } else { + $driver = new BlockingFilesystemDriver(); + } + filesystem($driver); + // Setup error reporting Shutdown::init(); set_error_handler(Exception::exceptionErrorHandler(...));