Skip to content

Commit

Permalink
Bug Fix for Install Update
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaythakkar authored and pietrocinaglia committed Dec 4, 2022
1 parent b6ac6e2 commit 5c2eed7
Show file tree
Hide file tree
Showing 13 changed files with 873 additions and 11 deletions.
20 changes: 20 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions src/LaraUpdaterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ private function log($msg, $append_response=false, $type='info'){
* Download and Install Update.
*/
public function update()
{
$this->log( trans("laraupdater.SYSTEM_VERSION") . $this->getCurrentVersion, true, 'info' );
{
$this->log( trans("laraupdater.SYSTEM_VERSION") . $this->getCurrentVersion(), true, 'info' );

if( ! $this->checkPermission() ){
$this->log( trans("laraupdater.PERMISSION_DENIED."), true, 'warn' );
Expand Down Expand Up @@ -90,11 +90,11 @@ public function update()

private function install($archive)
{
try{
try{
$execute_commands = false;
$update_script = base_path().'/'.config('laraupdater.tmp_folder_name').'/'.config('laraupdater.script_filename');

$zipHandle = zip_open($update_path);
$zipHandle = zip_open($archive);
$archive = substr($archive,0, -4);

$this->log( trans("laraupdater.CHANGELOG"), true, 'info' );
Expand All @@ -103,7 +103,7 @@ private function install($archive)
$filename = zip_entry_name($zip_item);
$dirname = dirname($filename);

// Exclude files
// Exclude files
if( substr($filename,-1,1) == '/' || dirname($filename) === $archive || substr($dirname,0,2) === '__') continue;
if($dirname === '.' ) continue;

Expand All @@ -129,7 +129,7 @@ private function install($archive)
$this->log( trans("laraupdater.FILE_EXIST") . $filename, true, 'info' );
$this->backup($filename); //backup current version
}

$this->log( trans("laraupdater.FILE_COPIED") . $filename, true, 'info' );

File::put(base_path().'/'.$filename, $contents);
Expand All @@ -149,7 +149,7 @@ private function install($archive)
$this->log( trans("laraupdater.EXECUTE_UPDATE_SCRIPT") . ' (\'upgrade.php\')', true, 'info' );
}

File::delete($update_path);
File::delete($archive);
File::deleteDirectory($this->tmp_backup_dir);
$this->log( trans("laraupdater.TEMP_CLEANED"), true, 'info' );

Expand All @@ -164,18 +164,18 @@ private function install($archive)
/*
* Download Update from $update_baseurl to $tmp_folder_name (local folder).
*/
private function download($filename) {
private function download($filename) {
$this->log( trans("laraupdater.DOWNLOADING"), true, 'info' );

$tmp_folder_name = base_path().'/'.config('laraupdater.tmp_folder_name');

if ( !is_dir($tmp_folder_name) )
File::makeDirectory($tmp_folder_name, $mode = 0755, true, true);

try{
$local_file = $tmp_folder_name.'/'.$filename;
$remote_file_url = config('laraupdater.update_baseurl').'/'.$filename;

$update = file_get_contents($remote_file_url);
file_put_contents($local_file, $update);

Expand Down Expand Up @@ -264,4 +264,4 @@ private function recovery(){
$this->log( trans("laraupdater.RECOVERY_SUCCESS"), true, 'info' );
return true;
}
}
}
7 changes: 7 additions & 0 deletions vendor/autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

// autoload.php @generated by Composer

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit55d2db31f01c0b409831fa009333a7d8::getLoader();
Loading

0 comments on commit 5c2eed7

Please sign in to comment.