@@ -24,6 +24,7 @@ final class Updater
2424 private $ exclude = [];
2525 private $ log = [];
2626 private $ status ;
27+ private $ clear ;
2728
2829 /**
2930 * Constructs a new instance of the class and starts the update process for the provided version.
@@ -42,7 +43,7 @@ final class Updater
4243 * 'filename' => an array of release excluded filenames
4344 * @return void
4445 */
45- public function __construct (string $ username , string $ repository , string $ token , string $ version , string |null $ admin = '' , string |null $ mailer = '' , array |null $ sourceExclusions = ['path ' => [], 'filename ' => []], array |null $ releaseExclusions = ['path ' => [], 'filename ' => []])
46+ public function __construct (string $ username , string $ repository , string $ token , string $ version , string |null $ admin = '' , string |null $ mailer = '' , array |null $ sourceExclusions = ['path ' => [], 'filename ' => []], array |null $ releaseExclusions = ['path ' => [], 'filename ' => []], bool $ clear = true )
4647 {
4748 $ this ->status = $ this ::STARTED ;
4849
@@ -83,6 +84,7 @@ public function __construct(string $username, string $repository, string $token,
8384 $ this ->admin = $ admin ;
8485 $ this ->mailer = $ mailer ;
8586 $ this ->exclude = ['source ' => $ sourceExclusions , 'release ' => $ releaseExclusions ];
87+ $ this ->clear = $ clear ;
8688
8789 $ this ->dir = getcwd ();
8890
@@ -305,7 +307,7 @@ private function Download($url = null)
305307 return false ;
306308 }
307309 } else {
308- $ download_file = $ this ->dir . "/update/update .zip " ;
310+ $ download_file = $ this ->dir . "/update/ " . $ this -> repository . " .zip " ;
309311 if (file_exists ($ download_file )) {
310312 $ this ->log [] = [date ("Y-m-d H:i:s " ), "Deleting existing zip file. $ download_file " ];
311313 if (!$ this ->Delete ($ download_file )) {
@@ -350,7 +352,7 @@ private function Download($url = null)
350352
351353 private function Extract ()
352354 {
353- $ download_file = $ this ->dir . "/update/update .zip " ;
355+ $ download_file = $ this ->dir . "/update/ " . $ this -> repository . " .zip " ;
354356 $ extract_path = $ this ->dir . "/update/extract " ;
355357 if (file_exists ($ extract_path )) {
356358 $ this ->log [] = [date ("Y-m-d H:i:s " ), "Deleting existing extract folder. $ extract_path " ];
@@ -483,10 +485,12 @@ private function CleanUp()
483485 $ this ->log [] = [date ("Y-m-d H:i:s " ), "Cleanup failed. " . $ this ->dir . "/update/extract " ];
484486 return false ;
485487 };
486- if (file_exists ($ this ->dir . "/update/update.zip " ) && !$ this ->Delete ($ this ->dir . "/update/update.zip " )) {
487- $ this ->log [] = [date ("Y-m-d H:i:s " ), "Cleanup failed. " . $ this ->dir . "/update/update.zip " ];
488- return false ;
489- };
488+ if ($ this ->clear ) {
489+ if (file_exists ($ this ->dir . "/update/ " . $ this ->repository . ".zip " ) && !$ this ->Delete ($ this ->dir . "/update/ " . $ this ->repository . ".zip " )) {
490+ $ this ->log [] = [date ("Y-m-d H:i:s " ), "Cleanup failed. " . $ this ->dir . "/update/ " . $ this ->repository . ".zip " ];
491+ return false ;
492+ };
493+ }
490494 $ this ->log [] = [date ("Y-m-d H:i:s " ), "Cleanup completed. " ];
491495 return true ;
492496 }
0 commit comments