From 51371674fc45bca7ab30aa5ab0d85c6ca02fcde6 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 19 Mar 2022 13:36:47 +1100 Subject: [PATCH] Self updater --- app/Http/Controllers/SelfUpdateController.php | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/SelfUpdateController.php b/app/Http/Controllers/SelfUpdateController.php index 89a3450bac93..d32100886aeb 100644 --- a/app/Http/Controllers/SelfUpdateController.php +++ b/app/Http/Controllers/SelfUpdateController.php @@ -87,6 +87,28 @@ class SelfUpdateController extends BaseController } + public function new_update() + { + + $contents = file_get_contents($this->getDownloadUrl()); + + Storage::disk('local')->put('invoiceninja.zip', $contents); + + $file = Storage::disk('local')->path('invoiceninja.zip'); + + $zipFile = new \PhpZip\ZipFile(); + + $zipFile->openFile($file); + + $zipFile->extractTo('/home/david/Downloads/1/'); + + $zipFile->close(); + + unlink($file); + + + } + private function testWritable() { $directoryIterator = new \RecursiveDirectoryIterator(base_path(), \RecursiveDirectoryIterator::SKIP_DOTS); @@ -117,7 +139,7 @@ class SelfUpdateController extends BaseController private function getDownloadUrl() { $version = $this->checkVersion(); - - return "https://github.com/invoiceninja/invoiceninja/releases/download/v{$verion}/invoiceninja.zip" + + return "https://github.com/invoiceninja/invoiceninja/releases/download/v{$version}/invoiceninja.zip" } }