mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-09-01 09:35:12 +00:00
checkup: drop images from db if not on the disk
This commit is contained in:
parent
6ec4d104ff
commit
2d7d0cd7d5
2 changed files with 11 additions and 16 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -8,6 +8,7 @@ bin/blocknotify
|
||||||
stratum/config/
|
stratum/config/
|
||||||
log/
|
log/
|
||||||
*.log
|
*.log
|
||||||
|
web/images/*
|
||||||
web/yaamp/runtime/*
|
web/yaamp/runtime/*
|
||||||
cookies/
|
cookies/
|
||||||
bin/blocknotif
|
bin/blocknotif
|
||||||
|
|
|
@ -178,23 +178,13 @@ class CheckupCommand extends CConsoleCommand
|
||||||
|
|
||||||
require_once($modelsPath.'/db_coinsModel.php');
|
require_once($modelsPath.'/db_coinsModel.php');
|
||||||
|
|
||||||
$obj = CActiveRecord::model('db_coins');
|
$coins = new db_coins;
|
||||||
$table = $obj->getTableSchema()->name;
|
if ($coins instanceof CActiveRecord)
|
||||||
|
|
||||||
try{
|
|
||||||
$test = new $obj;
|
|
||||||
} catch (Exception $e) {
|
|
||||||
echo "Error Model: $table \n";
|
|
||||||
echo $e->getMessage();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($test instanceof CActiveRecord)
|
|
||||||
{
|
{
|
||||||
echo "$table: ".$test->count()." records\n";
|
echo "".$coins->count()." coins in the database\n";
|
||||||
|
|
||||||
$nbUpdated = 0;
|
$nbUpdated = 0; $nbDropped = 0;
|
||||||
foreach ($test->findAll() as $coin) {
|
foreach ($coins->findAll() as $coin) {
|
||||||
if (!empty($coin->image)) {
|
if (!empty($coin->image)) {
|
||||||
if (file_exists($this->basePath.$coin->image))
|
if (file_exists($this->basePath.$coin->image))
|
||||||
continue;
|
continue;
|
||||||
|
@ -202,13 +192,17 @@ class CheckupCommand extends CConsoleCommand
|
||||||
$coin->image = "/images/coin-$coin->symbol.png";
|
$coin->image = "/images/coin-$coin->symbol.png";
|
||||||
$nbUpdated += $coin->save();
|
$nbUpdated += $coin->save();
|
||||||
}
|
}
|
||||||
|
if (!file_exists($this->basePath.$coin->image)) {
|
||||||
|
$coin->image = NULL;
|
||||||
|
$nbDropped += $coin->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (empty($coin->image) && file_exists($this->basePath."/images/coin-$coin->symbol.png")) {
|
if (empty($coin->image) && file_exists($this->basePath."/images/coin-$coin->symbol.png")) {
|
||||||
$coin->image = "/images/coin-$coin->symbol.png";
|
$coin->image = "/images/coin-$coin->symbol.png";
|
||||||
$nbUpdated += $coin->save();
|
$nbUpdated += $coin->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo "$nbUpdated images updated\n";
|
echo "$nbUpdated images updated, $nbDropped removed.\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue