diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 65b8dc72e..6305c7855 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,7 @@ jobs: strategy: matrix: php: + - '8.1' - '8.0' - '7.4' - '7.3' diff --git a/src/danog/MadelineProto/MTProtoTools/FilesLogic.php b/src/danog/MadelineProto/MTProtoTools/FilesLogic.php index 773e8dfaf..8407edd03 100644 --- a/src/danog/MadelineProto/MTProtoTools/FilesLogic.php +++ b/src/danog/MadelineProto/MTProtoTools/FilesLogic.php @@ -128,7 +128,8 @@ trait FilesLogic yield $stream->seek($offset); } } - return yield $stream->write($payload); + yield $stream->write($payload); + return \strlen($payload); }; return yield from $this->downloadToCallable($messageMedia, $callable, $cb, $seekable, $offset, $end); } diff --git a/src/danog/MadelineProto/SessionPaths.php b/src/danog/MadelineProto/SessionPaths.php index 5929a1bdb..6a9d37b96 100644 --- a/src/danog/MadelineProto/SessionPaths.php +++ b/src/danog/MadelineProto/SessionPaths.php @@ -25,6 +25,7 @@ use danog\MadelineProto\Ipc\IpcState; use function Amp\File\exists; use function Amp\File\openFile; +use function Amp\File\put; use function Amp\File\rename as renameAsync; use function Amp\File\stat; @@ -97,19 +98,17 @@ class SessionPaths try { Logger::log("Got exclusive lock of $path.lock..."); - $object = \serialize($object); + $object = Serialization::PHP_HEADER + .\chr(Serialization::VERSION) + .\chr(PHP_MAJOR_VERSION) + .\chr(PHP_MINOR_VERSION) + .\serialize($object); - $file = yield openFile("$path.temp.php", 'bw+'); - $l = yield $file->write(Serialization::PHP_HEADER); - $l += yield $file->write(\chr(Serialization::VERSION)); - $l += yield $file->write(\chr(PHP_MAJOR_VERSION)); - $l += yield $file->write(\chr(PHP_MINOR_VERSION)); - $l += yield $file->write($object); - yield $file->close(); + yield put( + "$path.temp.php", + $object + ); - if ($l !== ($need = \strlen(Serialization::PHP_HEADER)+3+\strlen($object))) { - throw new Exception("Did not write all the data (need $need, wrote $l)"); - } yield renameAsync("$path.temp.php", $path); } finally { $unlock();