Skip to content

Commit

Permalink
Accounting for non standard plugin packages when using plugin-install
Browse files Browse the repository at this point in the history
Some plugins .zip file decompress in non standard directory (e.g : zip file for atto_multilang2 decompresses into moodle-atto_multilang2-<version>; mod_hvp decompresses into 2 dir hvp and __MACOSX)
  • Loading branch information
montanae committed May 29, 2024
1 parent 33e9bc4 commit 20032db
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Moosh/Command/Generic/Plugin/PluginInstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public function execute()

if (!file_exists($tempdir)) {
mkdir($tempdir);
} else {
run_external_command("rm -rf $tempdir/*");
}

if (!fopen($downloadedfile, 'w')) {
Expand Down Expand Up @@ -96,9 +98,13 @@ public function execute()
}
}

run_external_command("unzip $downloadedfile -d $installpath");
run_external_command("unzip $downloadedfile -d $tempdir");
run_external_command("rm $downloadedfile");

//Get the path of uncompressed plugin dir (in case the .zip decompresses into multiple directories / non standard directory)
$uncompresseddir = exec("find $tempdir -name 'version.php' | rev | cut -d'/' -f 2- | rev");
run_external_command("mv $uncompresseddir $targetpath");

echo "Installing\n";
echo "\tname: $pluginname\n";
echo "\tversion: $version->version\n";
Expand Down

0 comments on commit 20032db

Please sign in to comment.