mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-12 15:02:11 +00:00
Hash update script for 302287.
This commit is contained in:
parent
1cd77bce7e
commit
0267bc8ac5
@ -1,11 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* Maintenance script for addons.mozilla.org.
|
||||
* The purpose of this script is to retro-actively update existing add-ons
|
||||
* with valid hashes.
|
||||
*
|
||||
* The purpose of this document is to perform periodic tasks that should not be
|
||||
* done everytime a download occurs in install.php. This should reduce
|
||||
* unnecessary DELETE and UPDATE queries and lighten the load on the database
|
||||
* backend.
|
||||
* We may not necessarily use this, but it was written just in case we need
|
||||
* to run the update in the future.
|
||||
*
|
||||
* This script should not ever be accessed over HTTP, and instead run via cron.
|
||||
* Only sysadmins should be responsible for operating this script.
|
||||
@ -28,19 +27,25 @@ require_once('../../public/inc/config.php');
|
||||
// For the addon object and db stuff
|
||||
require_once('../../public/inc/includes.php');
|
||||
|
||||
$path = '/data/amo/files/ftp/'; // Path to the directory that contains approved XPIs. Adjust to point to proper path.
|
||||
$versions = array();
|
||||
$hashes = array();
|
||||
|
||||
$db = new AMO_SQL();
|
||||
|
||||
$db->query("SELECT name,type,vid,uri FROM main m INNER JOIN version v ON v.id = m.id WHERE m.id=735", SQL_ALL, SQL_ASSOC);
|
||||
$db->query("SELECT name,version,type,vid,uri FROM main m INNER JOIN version v ON v.id = m.id WHERE v.approved='yes'", SQL_ALL, SQL_ASSOC);
|
||||
$versions=$db->record;
|
||||
|
||||
foreach($versions as $version) {
|
||||
// Here we are making some assumptions on the file path.
|
||||
// Change the first part if the server you are running on has the .xpi repository in a different location.
|
||||
$buf = sha1_file('/data/amo/files/ftp/'.($version['type']=='E'?'extensions/':'themes/').str_replace(' ','_',strtolower($version['name'])).'/'.basename($version['uri']));
|
||||
$db->query("UPDATE version SET hash='sha1:{$buf}' WHERE vid={$version['vid']}");
|
||||
|
||||
$file = '/data/amo/files/ftp/'.($version['type']=='E'?'extensions/':'themes/').str_replace(' ','_',strtolower($version['name'])).'/'.basename($version['uri']);
|
||||
|
||||
// If the file exists, get its sum and update its record.
|
||||
if (file_exists($file)) {
|
||||
$buf = sha1_file($file);
|
||||
$db->query("UPDATE version SET hash='sha1:{$buf}' WHERE vid={$version['vid']}");
|
||||
echo "Updated {$version['name']} {$version['version']} hash to sha1:{$buf}\n";
|
||||
}
|
||||
}
|
||||
|
||||
exit;
|
||||
|
Loading…
x
Reference in New Issue
Block a user