Skip to content

Commit

Permalink
FIX #16671 Can not generate zip file of documents in backup tool
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Mar 15, 2021
1 parent 7bbcf4a commit 614720f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion htdocs/admin/tools/export_files.php
Expand Up @@ -113,7 +113,8 @@
if ($compression == 'zip')
{
$file .= '.zip';
$ret = dol_compress_dir(DOL_DATA_ROOT, $outputdir."/".$file, $compression, '/(\.back|\.old|\.log|[\\\/]temp[\\\/]|documents[\\\/]admin[\\\/]documents[\\\/])/i');
$excludefiles = '/(\.back|\.old|\.log|[\/\\\]temp[\/\\\]|documents[\/\\\]admin[\/\\\]documents[\/\\\])/i';
$ret = dol_compress_dir(DOL_DATA_ROOT, $outputdir."/".$file, $compression, $excludefiles);
if ($ret < 0)
{
if ($ret == -2) {
Expand Down
7 changes: 7 additions & 0 deletions test/phpunit/FilesLibTest.php
Expand Up @@ -425,6 +425,13 @@ public function testDolCompressUnCompress()
$result=dol_uncompress($fileout, $dirout);
print __METHOD__." result=".join(',', $result)."\n";
$this->assertEquals(0, count($result), "Pb with dol_uncompress_file of file ".$fileout);

$excludefiles = '/(\.back|\.old|\.log|documents[\/\\\]admin[\/\\\]documents[\/\\\])/i';
if (preg_match($excludefiles, 'a/temp/b')) { echo '----- Regex OK -----'."\n"; }
$result=dol_compress_dir($dirout, $conf->admin->dir_temp.'/testdir.zip', 'zip', $excludefiles);
print __METHOD__." result=".$result."\n";
print join(', ', $conf->logbuffer);
$this->assertGreaterThanOrEqual(1, $result, "Pb with dol_compress_dir of ".$dirout." into ".$conf->admin->dir_temp.'/testdir.zip');
}

/**
Expand Down

2 comments on commit 614720f

@xusdeejay
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,
Thanks for your answer @eldy , the warnings error is resolved, but the resulting zip file does not correctly generate,the names or the structure of the directories in ionos hosting, however, same version Dolibarr13.0.1, there is no error in my other test installed on a Nas Synology, I think there may be some problem with IONOS.

WrongFoldersNames

@xusdeejay
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

@eldy ,Ionos uses a 7-bit version of Zip on my hosting, which causes the folders to not be structured well. Solution, Gzip or BZip2.

Jesus,

Thx

Please sign in to comment.