diff --git a/src/MTProto.php b/src/MTProto.php index 5f0b4de1b..f76b6382d 100644 --- a/src/MTProto.php +++ b/src/MTProto.php @@ -71,6 +71,7 @@ use Throwable; use Webmozart\Assert\Assert; use function Amp\async; +use function Amp\File\deleteFile; use function Amp\File\getSize; use function Amp\Future\await; @@ -1777,7 +1778,7 @@ final class MTProto implements TLCallback, LoggerGetter ], ], ); - \unlink($path); + deleteFile($path); } } $sent = false; diff --git a/src/MTProtoTools/Files.php b/src/MTProtoTools/Files.php index b0c2f61b3..0b69a18e6 100644 --- a/src/MTProtoTools/Files.php +++ b/src/MTProtoTools/Files.php @@ -851,7 +851,9 @@ trait Files $this->downloadToStream($messageMedia, $stream, $cb, $size, -1); } finally { $unlock(); - deleteFile("$file.lock"); + try { + deleteFile("$file.lock"); + } catch (Throwable) {} $stream->close(); } return $file;