Code simplification, move to wizard style UI, JSON file cache (scans every 15 mins)
This commit is contained in:
parent
75a7c9a13b
commit
92362efd47
11 changed files with 1027 additions and 438 deletions
35
build_media_cache.php
Normal file
35
build_media_cache.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/media_cache_lib.php';
|
||||
|
||||
if (PHP_SAPI !== 'cli') {
|
||||
fwrite(STDERR, "build_media_cache.php must run in CLI mode\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$resolveError = null;
|
||||
$baseDir = fm_resolve_media_root($resolveError);
|
||||
if ($baseDir === null) {
|
||||
fwrite(STDERR, ($resolveError ?? 'MEDIA_ROOT base directory not found') . PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$exitCode = 0;
|
||||
|
||||
foreach (['videos', 'music'] as $type) {
|
||||
$start = microtime(true);
|
||||
$rebuildError = null;
|
||||
$tree = fm_rebuild_cache($type, $baseDir, true, $rebuildError);
|
||||
$durationMs = (int)round((microtime(true) - $start) * 1000);
|
||||
|
||||
if (!is_array($tree)) {
|
||||
fwrite(STDERR, sprintf('[%s] cache rebuild failed: %s', $type, $rebuildError ?? 'unknown error') . PHP_EOL);
|
||||
$exitCode = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
fwrite(STDOUT, sprintf('[%s] cache rebuilt in %dms', $type, $durationMs) . PHP_EOL);
|
||||
}
|
||||
|
||||
exit($exitCode);
|
||||
Loading…
Add table
Add a link
Reference in a new issue