diff --git a/plugins/tar/tar.php b/plugins/tar/tar.php index add078d..3554622 100644 --- a/plugins/tar/tar.php +++ b/plugins/tar/tar.php @@ -1,5 +1,15 @@ &1"); -preg_match('/^Total bytes written: ([0-9]+) /', $out, $matches); -$totalsize = $matches[1]; +# compute and send content-length header +if ($SEND_CONTENT_LENGTH) { + $out = exec("tar $TAR_FLAGS --totals -cf /dev/null $filesarg 2>&1"); + preg_match('/^Total bytes written: ([0-9]+) /', $out, $matches); + $totalsize = $matches[1]; -header("Content-Length: $totalsize"); + header("Content-Length: $totalsize"); +} + +# final step : stream the directory content via tar header('Content-Type: application/x-tar'); header('Content-Disposition: attachment; filename="'.basename($realDir).'.tar"'); -passthru("tar --no-recursion -c $filesarg"); +passthru("tar $TAR_FLAGS -c $filesarg"); ?>