Add Compression flag
parent
e21a7a769b
commit
40292f3dad
|
|
@ -39,7 +39,8 @@ if ( canView('Events') ) {
|
|||
{
|
||||
require_once(ZM_SKIN_PATH.'/includes/export_functions.php');
|
||||
|
||||
# We use session vars in here, so we need to restart the session because we stopped it in index.php to improve concurrency.
|
||||
# We use session vars in here, so we need to restart the session
|
||||
# because we stopped it in index.php to improve concurrency.
|
||||
session_start();
|
||||
|
||||
if ( !empty($_REQUEST['exportDetail']) )
|
||||
|
|
@ -72,6 +73,11 @@ if ( canView('Events') ) {
|
|||
else
|
||||
$exportFormat = '';
|
||||
|
||||
if ( !empty($_REQUEST['exportCompress']) )
|
||||
$exportCompress = $_SESSION['export']['compress'] = $_REQUEST['exportCompress'];
|
||||
else
|
||||
$exportCompress = false;
|
||||
|
||||
session_write_close();
|
||||
|
||||
$exportIds = !empty($_REQUEST['eids'])?$_REQUEST['eids']:$_REQUEST['id'];
|
||||
|
|
@ -83,7 +89,8 @@ if ( canView('Events') ) {
|
|||
$exportImages,
|
||||
$exportVideo,
|
||||
$exportMisc,
|
||||
$exportFormat
|
||||
$exportFormat,
|
||||
$exportCompress
|
||||
) )
|
||||
ajaxResponse(array('exportFile'=>$exportFile));
|
||||
else
|
||||
|
|
@ -100,7 +107,8 @@ if ( canView('Events') ) {
|
|||
if ( $exportFile = exportEvents(
|
||||
$exportIds,
|
||||
(isset($_REQUEST['connkey'])?$_REQUEST['connkey']:''),
|
||||
false,false, false, $exportVideo, false, $exportFormat, $exportStructure ) )
|
||||
false,false, false,
|
||||
$exportVideo, false, $exportFormat, $exportStructure ) )
|
||||
ajaxResponse(array('exportFile'=>$exportFile));
|
||||
else
|
||||
ajaxError('Export Failed');
|
||||
|
|
|
|||
|
|
@ -826,6 +826,7 @@ function exportEvents(
|
|||
$exportVideo,
|
||||
$exportMisc,
|
||||
$exportFormat,
|
||||
$exportCompressed,
|
||||
$exportStructure = false
|
||||
) {
|
||||
|
||||
|
|
@ -912,28 +913,30 @@ function exportEvents(
|
|||
chdir(ZM_DIR_EXPORTS);
|
||||
$archive = '';
|
||||
if ( $exportFormat == 'tar' ) {
|
||||
$archive = ZM_DIR_EXPORTS.'/'.$export_root.($connkey?'_'.$connkey:'').'.tar.gz';
|
||||
@unlink($archive);
|
||||
$command = 'nice -10 tar --create --gzip --dereference --file='.escapeshellarg($archive).' zmExport_'.$connkey.'/';
|
||||
#$command = 'nice -10 tar --create --gzip --file='.escapeshellarg($archive).' --files-from='.escapeshellarg($listFile);
|
||||
$archive = ZM_DIR_EXPORTS.'/'.$export_root.($connkey?'_'.$connkey:'').'.tar';
|
||||
$command = 'tar --create --dereference';
|
||||
if ( $exportCompressed ) {
|
||||
$archive .= '.gz';
|
||||
$command .= ' --gzip';
|
||||
$exportFormat .= '.gz';
|
||||
}
|
||||
if ( $exportStructure == 'flat' ) {
|
||||
//strip file paths if we
|
||||
$command .= " --xform='s#^.+/##x'";
|
||||
}
|
||||
$command .= ' --file='.escapeshellarg($archive);
|
||||
} elseif ( $exportFormat == 'zip' ) {
|
||||
$archive = ZM_DIR_EXPORTS.'/'.$export_root.($connkey?'_'.$connkey:'').'.zip';
|
||||
@unlink($archive);
|
||||
if ( $exportStructure == 'flat' ) {
|
||||
$command = 'nice -10 zip -j '.escapeshellarg($archive).' zmExport_'.$connkey.'/';
|
||||
#$command = 'cat '.escapeshellarg($listFile).' | nice -10 zip -q -j '.escapeshellarg($archive).' -@';
|
||||
} else {
|
||||
$command = 'nice -10 zip -r '.escapeshellarg($archive).' zmExport_' . $connkey.'/';
|
||||
#$command = 'cat '.escapeshellarg($listFile).' | nice -10 zip -q '.escapeshellarg($archive).' -@';
|
||||
}
|
||||
$command = 'zip ';
|
||||
$command = ($exportStructure == 'flat' ? ' -j ' : ' -r ' ).escapeshellarg($archive);
|
||||
$command .= $exportCompressed ? ' -9' : ' -0';
|
||||
} else {
|
||||
Error("No exportFormat specified.");
|
||||
return false;
|
||||
} // if $exportFormat
|
||||
|
||||
@unlink($archive);
|
||||
$command .= ' zmExport_' . $connkey.'/';
|
||||
Logger::Debug("Command is $command");
|
||||
exec($command, $output, $status);
|
||||
if ( $status ) {
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ if ( isset($_SESSION['export']) ) {
|
|||
$_REQUEST['exportMisc'] = $_SESSION['export']['misc'];
|
||||
if ( isset($_SESSION['export']['format']) )
|
||||
$_REQUEST['exportFormat'] = $_SESSION['export']['format'];
|
||||
if ( isset($_SESSION['export']['compress']) )
|
||||
$_REQUEST['exportCompress'] = $_SESSION['export']['compress'];
|
||||
} else {
|
||||
$_REQUEST['exportDetail'] =
|
||||
$_REQUEST['exportFrames'] =
|
||||
|
|
|
|||
|
|
@ -28,10 +28,14 @@ $connkey = isset($_REQUEST['connkey'])?$_REQUEST['connkey']:'';
|
|||
|
||||
if ( $archivetype ) {
|
||||
switch ($archivetype) {
|
||||
case 'tar':
|
||||
case 'tar.gz':
|
||||
$mimetype = 'gzip';
|
||||
$file_ext = 'tar.gz';
|
||||
break;
|
||||
case 'tar':
|
||||
$mimetype = 'tar';
|
||||
$file_ext = 'tar';
|
||||
break;
|
||||
case 'zip':
|
||||
$mimetype = 'zip';
|
||||
$file_ext = 'zip';
|
||||
|
|
|
|||
Loading…
Reference in New Issue