the browser-facing portion of osu!
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add some messages when processing the db

nanaya fdb25eb9 dab1c5d1

+19 -2
+5 -1
app/Console/Commands/Ip2AsnUpdate.php
··· 15 15 16 16 public function handle() 17 17 { 18 - (new Ip2AsnUpdater())->run(); 18 + $this->info('Updating ip2asn database'); 19 + (new Ip2AsnUpdater())->run(function (string $message): void { 20 + $this->info($message); 21 + }); 22 + $this->info('Done'); 19 23 } 20 24 }
+14 -1
app/Libraries/Ip2AsnUpdater.php
··· 7 7 8 8 namespace App\Libraries; 9 9 10 + use Log; 11 + 10 12 class Ip2AsnUpdater 11 13 { 12 14 public static function getDbPath() ··· 19 21 return database_path('ip2asn.idx'); 20 22 } 21 23 22 - public function run(): void 24 + public function run(?callable $logger = null): void 23 25 { 26 + $logger ??= function (string $message) { 27 + Log::info("ip2asn: {$message}"); 28 + }; 29 + $logger('Checking db for updates'); 24 30 $dbPath = static::getDbPath(); 25 31 $indexPath = static::getIndexPath(); 26 32 ··· 31 37 32 38 $newIndex = !$dbExists || !file_exists($indexPath) || filemtime($dbPath) > filemtime($indexPath); 33 39 if (!$newDb && !$newIndex) { 40 + $logger('All relevant files are up to date'); 41 + 34 42 return; 35 43 } 36 44 45 + if ($newDb) { 46 + $logger('Db file is outdated. Downloading'); 47 + } 37 48 $tsv = $newDb 38 49 ? gzdecode(file_get_contents('https://iptoasn.com/data/ip2asn-combined.tsv.gz')) 39 50 : file_get_contents($dbPath); 40 51 52 + $logger('Indexing db'); 41 53 $currentLine = 0; 42 54 $index = pack('l', $currentLine); 43 55 while (($currentLine = strpos($tsv, "\n", $currentLine)) !== false) { ··· 47 59 } 48 60 } 49 61 62 + $logger('Writing db and index to file'); 50 63 if ($newDb) { 51 64 file_put_contents($dbPath, $tsv); 52 65 }