1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-11 17:14:07 +02:00

Reduce memory used by TAR export

This commit is contained in:
Jakub Vrana
2013-04-29 15:45:15 -07:00
parent 63c400f95d
commit 40c61f6cfc
3 changed files with 7 additions and 4 deletions

View File

@@ -84,7 +84,7 @@ SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
echo "\nDELIMITER ;;\n$triggers\nDELIMITER ;\n";
}
if ($ext == "tar") {
echo tar_file((DB != "" ? "" : "$db/") . "$name.csv", ob_get_clean());
tar_file((DB != "" ? "" : "$db/") . "$name.csv", ob_get_clean());
} elseif ($is_sql) {
echo "\n";
}

View File

@@ -412,7 +412,7 @@ function remove_definer($query) {
/** Get string to add a file in TAR
* @param string
* @param string
* @return string
* @return null prints the output
*/
function tar_file($filename, $contents) {
$return = pack("a100a8a8a8a12a12", $filename, 644, 0, 0, decoct(strlen($contents)), decoct(time()));
@@ -421,7 +421,10 @@ function tar_file($filename, $contents) {
$checksum += ord($return[$i]);
}
$return .= sprintf("%06o", $checksum) . "\0 ";
return $return . str_repeat("\0", 512 - strlen($return)) . $contents . str_repeat("\0", 511 - (strlen($contents) + 511) % 512);
echo $return;
echo str_repeat("\0", 512 - strlen($return));
echo $contents;
echo str_repeat("\0", 511 - (strlen($contents) + 511) % 512);
}
/** Get INI bytes value