1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-27 01:34:40 +01:00

Fix serialization during async construction

This commit is contained in:
Daniil Gentili 2019-05-03 20:30:30 +02:00
parent 406a2d8aad
commit 4c52776de9
3 changed files with 9 additions and 3 deletions

View File

@ -200,7 +200,7 @@ trait CallHandler
if (is_array($args) && isset($args['id']['_']) && isset($args['id']['dc_id']) && $args['id']['_'] === 'inputBotInlineMessageID') {
$aargs['datacenter'] = $args['id']['dc_id'];
}
if ($this->wrapper instanceof \danog\MadelineProto\API && isset($this->wrapper->session) && !is_null($this->wrapper->session) && time() - $this->wrapper->serialized > $this->settings['serialization']['serialization_interval']) {
if ($this->wrapper instanceof \danog\MadelineProto\API && isset($this->wrapper->session) && !is_null($this->wrapper->session) && time() - $this->wrapper->serialized > $this->settings['serialization']['serialization_interval'] && !$this->asyncInitPromise) {
$this->logger->logger("Didn't serialize in a while, doing that now...");
$this->wrapper->serialize($this->wrapper->session);
}

View File

@ -57,7 +57,13 @@ class Serialization
if ($filename == '') {
throw new \danog\MadelineProto\Exception('Empty filename');
}
if ($instance->API->asyncInitPromise) {
return $instance->call(static function () use ($filename, $instance, $force) {
yield $instance->API->asyncInitPromise;
$instance->API->asyncInitPromise = null;
return self::serialize($filename, $instance, $force);
});
}
if (isset($instance->API->setdem) && $instance->API->setdem) {
$instance->API->setdem = false;
$instance->API->__construct($instance->API->settings);