Fix Generation of zip of module

This commit is contained in:
Laurent Destailleur 2020-01-15 11:55:27 +01:00
parent 1292575371
commit 0442105bd4
2 changed files with 5 additions and 3 deletions

View File

@ -2071,9 +2071,10 @@ function dol_uncompress($inputfile, $outputdir)
* @param string $outputfile Target file name (output directory must exists and be writable)
* @param string $mode 'zip'
* @param string $excludefiles A regex pattern. For example: '/\.log$|\/temp\//'
* @param string $rootdirinzip Add a root dir level in zip file
* @return int <0 if KO, >0 if OK
*/
function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = '')
function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = '', $rootdirinzip = '')
{
$foundhandler=0;
@ -2134,7 +2135,8 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles =
{
// Get real and relative path for current file
$filePath = $file->getRealPath();
$relativePath = substr($filePath, strlen($inputdir) + 1);
$relativePath = ($rootdirinzip ? $rootdirinzip.'/' : '').substr($filePath, strlen($inputdir) + 1);
if (empty($excludefiles) || ! preg_match($excludefiles, $filePath))
{
// Add current file to archive

View File

@ -1071,7 +1071,7 @@ if ($dirins && $action == 'generatepackage')
if ($dirofmodule)
{
if (! dol_is_dir($dirofmodule)) dol_mkdir($dirofmodule);
$result = dol_compress_dir($dir, $outputfilezip, 'zip');
$result = dol_compress_dir($dir, $outputfilezip, 'zip', '', $modulelowercase);
}
else
{