mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-27 07:14:39 +01:00
Bugfixes
This commit is contained in:
parent
0514b5fcf5
commit
4c1fb332f5
@ -178,7 +178,7 @@ class API extends InternalDoc
|
||||
$this->session = new SessionPaths($session);
|
||||
$this->wrapper = new APIWrapper($this, $this->exportNamespace());
|
||||
|
||||
$this->setInitPromise((function () use ($settings) { yield new \Amp\Success; return yield from $this->internalInitAPI($settings); })());
|
||||
$this->setInitPromise($this->internalInitAPI($settings));
|
||||
foreach (\get_class_vars(APIFactory::class) as $key => $var) {
|
||||
if (\in_array($key, ['namespace', 'API', 'lua', 'async', 'asyncAPIPromise', 'methods'])) {
|
||||
continue;
|
||||
|
@ -34,7 +34,7 @@ class AsyncConstruct
|
||||
/**
|
||||
* Async init promise.
|
||||
*
|
||||
* @var Promise|null|boolean
|
||||
* @var Promise|\Generator|null|boolean
|
||||
*/
|
||||
private $asyncInitPromise;
|
||||
/**
|
||||
@ -46,6 +46,7 @@ class AsyncConstruct
|
||||
{
|
||||
if ($this->asyncInitPromise) {
|
||||
Tools::wait($this->asyncInitPromise);
|
||||
$this->asyncInitPromise = null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
@ -57,6 +58,7 @@ class AsyncConstruct
|
||||
{
|
||||
if ($this->asyncInitPromise) {
|
||||
yield $this->asyncInitPromise;
|
||||
$this->asyncInitPromise = null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
@ -90,13 +92,6 @@ class AsyncConstruct
|
||||
*/
|
||||
public function setInitPromise($promise): void
|
||||
{
|
||||
$this->asyncInitPromise = Tools::call($promise);
|
||||
$this->asyncInitPromise->onResolve(
|
||||
function (?\Throwable $error, $result): void {
|
||||
if (!$error) {
|
||||
$this->asyncInitPromise = null;
|
||||
}
|
||||
}
|
||||
);
|
||||
$this->asyncInitPromise = $promise;
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +192,9 @@ class Server extends SignalLoop
|
||||
if ($payload === self::SHUTDOWN) {
|
||||
$this->signal(null);
|
||||
if (self::$shutdownDeferred) {
|
||||
self::$shutdownDeferred->resolve();
|
||||
$deferred = self::$shutdownDeferred;
|
||||
self::$shutdownDeferred = null;
|
||||
$deferred->resolve();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -782,7 +782,7 @@ trait Files
|
||||
{
|
||||
if (\is_object($dir) && $dir instanceof FileCallbackInterface) {
|
||||
$cb = $dir;
|
||||
$dir = $dir->getFile();
|
||||
$dir = yield $dir->getFile();
|
||||
}
|
||||
$messageMedia = (yield from $this->getDownloadInfo($messageMedia));
|
||||
return yield from $this->downloadToFile($messageMedia, $dir.'/'.$messageMedia['name'].$messageMedia['ext'], $cb);
|
||||
@ -802,7 +802,7 @@ trait Files
|
||||
{
|
||||
if (\is_object($file) && $file instanceof FileCallbackInterface) {
|
||||
$cb = $file;
|
||||
$file = $file->getFile();
|
||||
$file = yield $file->getFile();
|
||||
}
|
||||
$file = Tools::absolute(\preg_replace('|/+|', '/', $file));
|
||||
if (!yield exists($file)) {
|
||||
@ -848,7 +848,7 @@ trait Files
|
||||
$messageMedia = (yield from $this->getDownloadInfo($messageMedia));
|
||||
if (\is_object($callable) && $callable instanceof FileCallbackInterface) {
|
||||
$cb = $callable;
|
||||
$callable = $callable->getFile();
|
||||
$callable = yield $callable->getFile();
|
||||
}
|
||||
if (!\is_callable($callable)) {
|
||||
throw new Exception('Wrong callable provided');
|
||||
|
Loading…
Reference in New Issue
Block a user