diff --git a/libraries/optimizer.php b/libraries/optimizer.php
index dbea1aa..77a13e2 100644
--- a/libraries/optimizer.php
+++ b/libraries/optimizer.php
@@ -1,4 +1,5 @@
get_folders() as $folder)
{
- $time_start = microtime(true);
self::build_removand_sublist($queue, $folder, $single_level);
- $time_end = microtime(true);
- $times_c[$folder] = $time_end - $time_start;
}
- $time_2 = microtime(true);
-
- arsort($times_c);
- $times_c = array_splice($times_c, 0, 100);
-
- $time_3 = $time_2-$time_1;
- echo "{$time_3}
";
- echo "
";
- print_r($times_c);
- echo "
";
return $queue;
}
- public static function build_excluded_list(osu_library $library) : array
+ public static function build_excluded_list(osu_library $library, bool $nuke = false) : array
{
$background_files = $library->get_backgrounds();
$video_files = $library->get_videos();
$audio_files = $library->get_audiofiles();
- $storyboard_files = $library->get_storyboards();
- $hitsound_files = $library->get_hitsounds();
-
- // $osu_files = $library->get_osu_files();
- // $osb_files = $library->get_osb_files();
- $physical_excluded = $library->get_parsed_files();
-
$essential_excluded = array_merge($background_files, $video_files, $audio_files);
- // $physical_excluded = array_merge($osb_files, $osu_files);
- $other_excluded = array_merge($storyboard_files, $hitsound_files);
- $excluded = array_merge($essential_excluded, $physical_excluded, $other_excluded);
+ if (!$nuke)
+ {
+ $storyboard_files = $library->get_storyboards();
+ $hitsound_files = $library->get_hitsounds();
+
+ // $osu_files = $library->get_osu_files();
+ // $osb_files = $library->get_osb_files();
+ $physical_excluded = $library->get_parsed_files();
+
+ // $physical_excluded = array_merge($osb_files, $osu_files);
+ $other_excluded = array_merge($storyboard_files, $hitsound_files);
+
+ $excluded = array_merge($essential_excluded, $physical_excluded, $other_excluded);
+ }
+ else
+ {
+ $excluded = $essential_excluded;
+ }
return $excluded;
}
@@ -192,16 +186,14 @@ class optimizer
{
if (self::is_skinnable_image($file) || self::is_skinnable_other($file))
{
- // if (file_exists($file)) unlink($file);
- echo $file . "
";
+ if (file_exists($file)) unlink($file);
}
}
- exit(0); // testing purposes
}
public static function remove_hitsounds(osu_library $library) : void
{
- $removand = self::build_single_level_removand_list($library, true);
+ $removand = self::build_removand_list($library, true);
$exclusions = self::build_excluded_list($library);
$junk_files = self::array_diff_ver_peppy($removand, $exclusions);
@@ -215,19 +207,22 @@ class optimizer
}
}
- public static function remove_other(osu_library $library) : void
+ public static function full_nuke(osu_library $library) : void
+ {
+ self::remove_other($library, true);
+ }
+
+ public static function remove_other(osu_library $library, bool $nuke = false) : void
{
$removand = self::build_removand_list($library);
- $exclusions = self::build_excluded_list($library);
+ $exclusions = self::build_excluded_list($library, $nuke);
$junk_files = self::array_diff_ver_peppy($removand, $exclusions);
foreach ($junk_files as $file)
{
if (self::is_skinnable($file)) continue; // ignore default hitsounds
- // if (file_exists($file)) unlink($file);
- echo $file . "
";
+ if (file_exists($file)) unlink($file);
}
- exit(0); // testing purposes
}
}
\ No newline at end of file
diff --git a/libraries/osu_cacher.php b/libraries/osu_cacher.php
index 16d1236..365adda 100644
--- a/libraries/osu_cacher.php
+++ b/libraries/osu_cacher.php
@@ -1,6 +1,9 @@
is_cached($path)) return false;
-
+
$raw = file_get_contents($this->get_cached_path($path));
$json = json_decode($raw, true);
@@ -51,7 +54,7 @@ class osu_cacher
$cache_dir = dirname($cache_path);
if (!file_exists($cache_dir)) mkdir($cache_dir, 0777, true);
- if (!isset($content["hash"])) $content["hash"] = hash_file("md5", $path);
+ if (!isset($content["hash"])) $content["hash"] = hash_file(self::$hash_function, $path);
$encoded = json_encode($content);
file_put_contents($cache_path, $encoded);
diff --git a/libraries/osu_library.php b/libraries/osu_library.php
index 688ef3a..fe8973d 100644
--- a/libraries/osu_library.php
+++ b/libraries/osu_library.php
@@ -118,13 +118,16 @@ class osu_library
$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);
$parser = new osu_parser($cacher);
foreach ($glob as $file)
{
$difficulty_key = basename($file);
+
$difficulty = $parser->parse_osu_file_format($file);
+
$difficulty["key"] = $difficulty_key;
$difficulty["path"] = $file;
diff --git a/libraries/osu_parser.php b/libraries/osu_parser.php
index 4543e0f..5e56dc7 100644
--- a/libraries/osu_parser.php
+++ b/libraries/osu_parser.php
@@ -60,7 +60,9 @@ class osu_parser
if (!$skip_cache)
{
- $cached = $this->cacher->get_cache($path, hash_file("md5", $path));
+ $hash = hash_file(osu_cacher::$hash_function, $path);
+
+ $cached = $this->cacher->get_cache($path, $hash);
if ($cached !== false) return $cached;
}
@@ -215,6 +217,7 @@ class osu_parser
$time_end = microtime(true);
$parsing_time = $time_end - $time_start;
$parsed["parsing_time"] = $parsing_time;
+ if (!empty($hash)) $parsed["hash"] = $hash;
if (!$skip_cache)
{