Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

collection_download_process_archive_command()

Description

Executes the archiver command when downloading a collection.


False when further processing needed e.g. when producing a zip file.

Parameters

ColumnTypeDefaultDescription
$collection_download_tar boolean
&$zip
$filename string
$usertempdir string
$archiver boolean
$settings_id integer
&$zipfile
$zip object
$zipfile string

Return

bool Will return true if there is no further work to be done as will be the case for a tar file.

Location

include/collections_functions.php lines 5141 to 5196

Definition

 
function collection_download_process_archive_command($collection_download_tar, &$zip$filename$usertempdir$archiver$settings_id, &$zipfile)
    {
    global 
$lang$use_zip_extension$collection_download_settings$archiver_listfile_argument$cmdfile$config_windows,$zipcommand;

    
$archiver_fullpath get_utility_path("archiver");

    
# Execute the archiver command.
    # If $collection_download is true the $collection_download_settings are used if defined, else the legacy $zipcommand is used.
    
if ($use_zip_extension && !$collection_download_tar)
        {
        
update_zip_progress_file("zipping");
        
$GLOBALS["use_error_exception"]=true;
        try
            {
            
$zip->close();
            }
        catch (
Throwable $e)
            {
            
debug("collection_download_process_archive_command: Unable to close zip file. Reason {$e->getMessage()}");
            }
        unset(
$GLOBALS["use_error_exception"]);
        
update_zip_progress_file("complete");
        
sleep(1);
        }
     elseif (
$collection_download_tar)
        {
        
header("Content-type: application/tar");
        
header("Content-disposition: attachment; filename=" $filename );
        
debug("collection_download tar command: tar -cv -C " $usertempdir " . ");
        
$cmdtempdir escapeshellarg($usertempdir);
        
passthru("find " $cmdtempdir ' -printf "%P\n" | tar -cv --no-recursion --dereference -C ' $cmdtempdir " -T -");
        return 
true;
        }
    elseif (
$archiver)
        {
        
update_zip_progress_file("zipping");
        
run_command($archiver_fullpath " " $collection_download_settings[$settings_id]["arguments"] . " " escapeshellarg($zipfile) . " " $archiver_listfile_argument escapeshellarg($cmdfile));
        
update_zip_progress_file("complete");
        }
    elseif (!
$use_zip_extension)
        {
        
update_zip_progress_file("zipping");    
        if (
$config_windows)
            
# Add the command file, containing the filenames, as an argument.
            
{
            
exec("$zipcommand " escapeshellarg($zipfile) . " @" escapeshellarg($cmdfile));
            }
        else
            {
            
# Pipe the command file, containing the filenames, to the executable.
            
exec("$zipcommand " escapeshellarg($zipfile) . " -@ < " escapeshellarg($cmdfile));
            }
            
update_zip_progress_file("complete");
        }
    return 
false;
    }

This article was last updated 19th March 2024 07:05 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.