From 04ef869abae8dd0f074316dee9ad8c966ec7c513 Mon Sep 17 00:00:00 2001 From: Squidly271 Date: Sat, 18 May 2024 10:28:43 -0400 Subject: [PATCH] Refactor --- emhttp/plugins/dynamix/include/Wrappers.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/emhttp/plugins/dynamix/include/Wrappers.php b/emhttp/plugins/dynamix/include/Wrappers.php index e68d8c5ad..0569aaf54 100644 --- a/emhttp/plugins/dynamix/include/Wrappers.php +++ b/emhttp/plugins/dynamix/include/Wrappers.php @@ -29,12 +29,10 @@ function file_put_contents_atomic($filename,$data, $flags = 0, $context = null) break; } $renResult = false; - $copyResult = @copy($filename,"$filename$suffix"); - if ( $copyResult ) { - if (file_put_contents("$filename$suffix",$data,$flags,$context) === strlen($data)) - $renResult = @rename("$filename$suffix",$filename); - } - if ( (! $copyResult || ! $renResult) ) { + $writeResult = @file_put_contents("$filename$suffix",$data,$flags,$context) === strlen($data); + if ( $writeResult ) + $renResult = @rename("$filename$suffix",$filename); + if ( ! $writeResult || ! $renResult ) { my_logger("File_put_contents_atomic failed to write / rename $filename"); @unlink("$filename$suffix"); return false;