Normal scan option added
This commit is contained in:
@@ -29,14 +29,22 @@ class osu_library
|
|||||||
|
|
||||||
$this->set_root($root); // update db entry
|
$this->set_root($root); // update db entry
|
||||||
|
|
||||||
$this->clear_library();
|
|
||||||
$glob = glob($this->get_library_folder() . "/*", GLOB_ONLYDIR);
|
$glob = glob($this->get_library_folder() . "/*", GLOB_ONLYDIR);
|
||||||
|
|
||||||
|
$library = $this->get_library();
|
||||||
natsort($glob); // i like wasting your processing power
|
natsort($glob); // i like wasting your processing power
|
||||||
foreach($glob as $folder)
|
foreach($glob as $folder)
|
||||||
|
{
|
||||||
|
$key = basename($folder);
|
||||||
|
if (isset($library[$key]))
|
||||||
|
{
|
||||||
|
$this->scan_check_folder($folder);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
$this->scan_add_folder($folder);
|
$this->scan_add_folder($folder);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$time_end = microtime(true);
|
$time_end = microtime(true);
|
||||||
$scanning_time = $time_end - $time_start;
|
$scanning_time = $time_end - $time_start;
|
||||||
@@ -54,6 +62,37 @@ class osu_library
|
|||||||
unset($this->db["library"]);
|
unset($this->db["library"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function scan_check_folder(string $folder) : void
|
||||||
|
{
|
||||||
|
$key = basename($folder);
|
||||||
|
|
||||||
|
$osu_glob = glob(utils::globsafe($folder) . "/*.osu");
|
||||||
|
$osb_glob = glob(utils::globsafe($folder) . "/*.osb");
|
||||||
|
$glob = array_merge($osu_glob, $osb_glob);
|
||||||
|
|
||||||
|
$cacher = new osu_cacher($this->get_library_folder(), self::$cache_root);
|
||||||
|
|
||||||
|
$changed = false;
|
||||||
|
if (count($osu_glob) < 1)
|
||||||
|
{
|
||||||
|
$changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($glob as $file)
|
||||||
|
{
|
||||||
|
if ($cacher->get_cache($file) === false)
|
||||||
|
{
|
||||||
|
$changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($changed)
|
||||||
|
{
|
||||||
|
unset($this->db["library"][$key]);
|
||||||
|
$this->scan_add_folder($folder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function scan_add_folder(string $folder) : void
|
private function scan_add_folder(string $folder) : void
|
||||||
{
|
{
|
||||||
$key = basename($folder);
|
$key = basename($folder);
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ class osu_parser
|
|||||||
unset($file); // remove the memory leak
|
unset($file); // remove the memory leak
|
||||||
|
|
||||||
// storyboards are overloaded with dupes (renumber to make json export to arrays)
|
// storyboards are overloaded with dupes (renumber to make json export to arrays)
|
||||||
$parsed["storyboard"] = array_values(array_unique($parsed["storyboard"]));
|
if (!empty($parsed["storyboard"])) $parsed["storyboard"] = array_values(array_unique($parsed["storyboard"]));
|
||||||
|
|
||||||
$time_end = microtime(true);
|
$time_end = microtime(true);
|
||||||
$parsing_time = $time_end - $time_start;
|
$parsing_time = $time_end - $time_start;
|
||||||
|
|||||||
@@ -27,6 +27,13 @@ function redirect($path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET["rescan"]))
|
if (isset($_GET["rescan"]))
|
||||||
|
{
|
||||||
|
$lib->rescan_library(json_decode(file_get_contents("session/settings.json"), true)["osu_folder"]);
|
||||||
|
$lib->save_db();
|
||||||
|
redirect("./");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_GET["scan"]))
|
||||||
{
|
{
|
||||||
$lib->scan_library(json_decode(file_get_contents("session/settings.json"), true)["osu_folder"]);
|
$lib->scan_library(json_decode(file_get_contents("session/settings.json"), true)["osu_folder"]);
|
||||||
$lib->save_db();
|
$lib->save_db();
|
||||||
@@ -61,7 +68,8 @@ $start = file_get_contents("resources/start.html");
|
|||||||
$start = str_replace("{{ STYLE }}", file_get_contents("resources/style.css"), $start);
|
$start = str_replace("{{ STYLE }}", file_get_contents("resources/style.css"), $start);
|
||||||
echo $start;
|
echo $start;
|
||||||
dump($lib, "lib");
|
dump($lib, "lib");
|
||||||
echo '<a href="./?rescan">[Rescan]</a> ';
|
echo '<a href="./?scan">[Scan]</a> ';
|
||||||
|
echo '<a href="./?rescan">[Force rescan]</a> ';
|
||||||
echo '<a href="./?blacken">[Blacken]</a> ';
|
echo '<a href="./?blacken">[Blacken]</a> ';
|
||||||
echo '<a href="./?nosb">[NoSB]</a> ';
|
echo '<a href="./?nosb">[NoSB]</a> ';
|
||||||
echo '<a href="./?novid">[Novid]</a> ';
|
echo '<a href="./?novid">[Novid]</a> ';
|
||||||
|
|||||||
Reference in New Issue
Block a user