From 12f4e7dbf48f774b219dc943d95858b2ef237021 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sat, 10 Apr 2021 12:29:50 +0200 Subject: [PATCH] Avoid race conditions --- tools/phar.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/phar.php b/tools/phar.php index f7e668d12..561ec7431 100644 --- a/tools/phar.php +++ b/tools/phar.php @@ -52,7 +52,7 @@ function ___install_madeline() $contents = \file_get_contents($file); if (\strpos($contents, 'new \danog\MadelineProto\Server') && \in_array($contents, [@\file_get_contents('https://github.com/danog/MadelineProtoPhar/raw/2270bd9a94d168a5e6731ffd7e61821ea244beff/mtproxyd'), @\file_get_contents('https://github.com/danog/MadelineProtoPhar/raw/7cabb718ec3ccb79e3c8e3d34f5bccbe3f63b0fd/mtproxyd')]) && ($mtproxyd = @\file_get_contents('https://phar.madelineproto.xyz/mtproxyd?v=new'))) { - \file_put_contents($file, $mtproxyd); + \file_put_contents($file, $mtproxyd, LOCK_EX); return; } @@ -121,8 +121,8 @@ function ___install_madeline() } $previous['danog/madelineproto'] = 'old'; - \file_put_contents($madeline_phar, $phar); - \file_put_contents("$madeline_phar.version", $release); + \file_put_contents($madeline_phar, $phar, LOCK_EX); + \file_put_contents("$madeline_phar.version", $release, LOCK_EX); $current = $extractVersions(); $postData = ['downloads' => []];