mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-26 22:34:42 +01:00
Workaround undocumented amphp/file v2 quirk
This commit is contained in:
parent
5969ebe783
commit
45b72b8d70
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
@ -6,6 +6,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
php:
|
php:
|
||||||
|
- '8.1'
|
||||||
- '8.0'
|
- '8.0'
|
||||||
- '7.4'
|
- '7.4'
|
||||||
- '7.3'
|
- '7.3'
|
||||||
|
@ -128,7 +128,8 @@ trait FilesLogic
|
|||||||
yield $stream->seek($offset);
|
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);
|
return yield from $this->downloadToCallable($messageMedia, $callable, $cb, $seekable, $offset, $end);
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ use danog\MadelineProto\Ipc\IpcState;
|
|||||||
|
|
||||||
use function Amp\File\exists;
|
use function Amp\File\exists;
|
||||||
use function Amp\File\openFile;
|
use function Amp\File\openFile;
|
||||||
|
use function Amp\File\put;
|
||||||
use function Amp\File\rename as renameAsync;
|
use function Amp\File\rename as renameAsync;
|
||||||
use function Amp\File\stat;
|
use function Amp\File\stat;
|
||||||
|
|
||||||
@ -97,19 +98,17 @@ class SessionPaths
|
|||||||
try {
|
try {
|
||||||
Logger::log("Got exclusive lock of $path.lock...");
|
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+');
|
yield put(
|
||||||
$l = yield $file->write(Serialization::PHP_HEADER);
|
"$path.temp.php",
|
||||||
$l += yield $file->write(\chr(Serialization::VERSION));
|
$object
|
||||||
$l += yield $file->write(\chr(PHP_MAJOR_VERSION));
|
);
|
||||||
$l += yield $file->write(\chr(PHP_MINOR_VERSION));
|
|
||||||
$l += yield $file->write($object);
|
|
||||||
yield $file->close();
|
|
||||||
|
|
||||||
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);
|
yield renameAsync("$path.temp.php", $path);
|
||||||
} finally {
|
} finally {
|
||||||
$unlock();
|
$unlock();
|
||||||
|
Loading…
Reference in New Issue
Block a user