Skip to content
Permalink
Browse files

Add filesizes

  • Loading branch information...
Marlamin committed Sep 10, 2019
1 parent 9096f24 commit 6965513a9eb722d8e221fbef397896319fef977a
Showing with 39 additions and 3 deletions.
  1. +7 −3 files/scripts/filedata_api.php
  2. +32 −0 files/scripts/updateSizes.php
@@ -30,7 +30,7 @@
}
$contenthashes = array();
$subq = $pdo->prepare("SELECT wow_rootfiles_chashes.root_cdn, wow_rootfiles_chashes.contenthash, wow_buildconfig.hash as buildconfig, wow_buildconfig.description FROM wow_rootfiles_chashes LEFT JOIN wow_buildconfig on wow_buildconfig.root_cdn=wow_rootfiles_chashes.root_cdn WHERE filedataid = :id ORDER BY wow_buildconfig.description DESC");
$subq = $pdo->prepare("SELECT wow_rootfiles_chashes.root_cdn, wow_rootfiles_chashes.contenthash, wow_rootfiles_sizes.size, wow_buildconfig.hash as buildconfig, wow_buildconfig.description FROM wow_rootfiles_chashes LEFT JOIN wow_buildconfig on wow_buildconfig.root_cdn=wow_rootfiles_chashes.root_cdn LEFT OUTER JOIN wow_rootfiles_sizes on wow_rootfiles_sizes.contenthash=wow_rootfiles_chashes.contenthash WHERE filedataid = :id ORDER BY wow_buildconfig.description DESC");
$subq->bindParam(":id", $row['id'], PDO::PARAM_INT);
$subq->execute();
$versions = array();
@@ -46,6 +46,10 @@
continue;
}
if(empty($subrow['size'])){
$subrow['size'] = 0;
}
$versions[] = $subrow;
}
@@ -86,9 +90,9 @@
echo "<tr><td colspan='2'><b>Known versions</b></td></tr>";
echo "<tr><td colspan='2'>
<table class='table table-condensed'>";
echo "<tr><th>Description</th><th>Buildconfig</th><th>Contenthash</th><th>&nbsp;</th></tr>";
echo "<tr><th>Description</th><th>Buildconfig</th><th>Contenthash</th><th>Size</th><th>&nbsp;</th></tr>";
foreach($versions as $version){
echo "<tr><td>".$version['description']."</td><td class='hash'>".$version['buildconfig']."</td><td class='hash'><a href='#' data-toggle='modal' data-target='#chashModal' onClick='fillChashModal(\"".$version['contenthash']."\")'>".$version['contenthash']."</a></td>";
echo "<tr><td>".$version['description']."</td><td class='hash'>".$version['buildconfig']."</td><td class='hash'><a href='#' data-toggle='modal' data-target='#chashModal' onClick='fillChashModal(\"".$version['contenthash']."\")'>".$version['contenthash']."</a></td><td>".$version['size']." bytes</td>";
echo "<td><a href='#' data-toggle='modal' data-target='#previewModal' onClick='fillPreviewModal(\"".$version['buildconfig']."\", \"".$returndata['filedataid']."\")'>Preview</a></td>";
echo "</tr>";
}
@@ -0,0 +1,32 @@
<?php
include("../../inc/config.php");
if(php_sapi_name() != "cli") die("This script cannot be run outside of CLI.");
if(empty($argv[1])){
die("Need buildconfig as argument");
}
$q = $pdo->prepare("SELECT hash, description FROM wow_buildconfig WHERE hash = ?");
$q->execute([$argv[1]]);
$row = $q->fetch();
// foreach($pdo->query("SELECT hash, description FROM wow_buildconfig ORDER BY builton ASC") as $row){
echo "Updating sizes for ".$row['description']."\n";
$tempname = tempnam("/tmp", "SIZES");
$output = shell_exec("cd /home/wow/buildbackup; /usr/bin/dotnet BuildBackup.dll dumpsizes wow ".escapeshellarg($row['hash'])." > ".escapeshellarg($tempname));
$pdo->exec("
LOAD DATA LOCAL INFILE '".$tempname."'
INTO TABLE `wow_rootfiles_sizes`
FIELDS TERMINATED BY ' ' ESCAPED BY '\b'
LINES TERMINATED BY '\n'
(contenthash, size)
");
unlink($tempname);
// }
?>

0 comments on commit 6965513

Please sign in to comment.
You can’t perform that action at this time.