File existence safety
This commit is contained in:
@@ -38,7 +38,7 @@ class optimizer
|
||||
unlink($file);
|
||||
}
|
||||
|
||||
foreach ($library->get_storyboard_files() as $file)
|
||||
foreach ($library->get_osb_files() as $file)
|
||||
{
|
||||
unlink($file);
|
||||
}
|
||||
@@ -118,7 +118,7 @@ class optimizer
|
||||
$vid = $library->get_videos();
|
||||
$sb = $library->get_storyboards();
|
||||
$a = $library->get_audiofiles();
|
||||
$sbf = $library->get_storyboard_files();
|
||||
$sbf = $library->get_osb_files();
|
||||
$osf = $library->get_osu_files();
|
||||
$excluded = array_merge($bg, $vid, $sb, $a, $sbf, $osf);
|
||||
|
||||
|
||||
+24
-11
@@ -250,12 +250,15 @@ class osu_library
|
||||
$folders = array();
|
||||
foreach ($db as $beatmapset)
|
||||
{
|
||||
$backgrounds[] = $beatmapset["path"];
|
||||
if (file_exists($beatmapset["path"]))
|
||||
{
|
||||
$folders[] = $beatmapset["path"];
|
||||
}
|
||||
}
|
||||
|
||||
$backgrounds = array_unique($backgrounds);
|
||||
$folders = array_unique($folders);
|
||||
|
||||
return $backgrounds;
|
||||
return $folders;
|
||||
}
|
||||
|
||||
public function get_backgrounds() : array
|
||||
@@ -269,7 +272,8 @@ class osu_library
|
||||
{
|
||||
if (!empty($beatmap["background"]))
|
||||
{
|
||||
$backgrounds[] = $beatmapset["path"] . "/" . $beatmap["background"];
|
||||
$path = $beatmapset["path"] . "/" . $beatmap["background"];
|
||||
if (file_exists($path)) $backgrounds[] = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -290,7 +294,8 @@ class osu_library
|
||||
{
|
||||
if (!empty($beatmap["video"]))
|
||||
{
|
||||
$videos[] = $beatmapset["path"] . "/" . $beatmap["video"];
|
||||
$path = $beatmapset["path"] . "/" . $beatmap["video"];
|
||||
if (file_exists($path)) $videos[] = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -311,7 +316,10 @@ class osu_library
|
||||
{
|
||||
if (!empty($beatmap["format"]) && $beatmap["format"] != "storyboard")
|
||||
{
|
||||
$osu_files[] = $beatmap["path"];
|
||||
if (file_exists($beatmap["path"]))
|
||||
{
|
||||
$osu_files[] = $beatmap["path"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -321,7 +329,7 @@ class osu_library
|
||||
return $osu_files;
|
||||
}
|
||||
|
||||
public function get_storyboard_files() : array
|
||||
public function get_osb_files() : array
|
||||
{
|
||||
$db = $this->get_library();
|
||||
|
||||
@@ -332,7 +340,10 @@ class osu_library
|
||||
{
|
||||
if (!empty($beatmap["format"]) && $beatmap["format"] == "storyboard")
|
||||
{
|
||||
$storyboard_files[] = $beatmap["path"];
|
||||
if (file_exists($beatmap["path"]))
|
||||
{
|
||||
$storyboard_files[] = $beatmap["path"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -353,7 +364,8 @@ class osu_library
|
||||
{
|
||||
foreach ($beatmap["storyboard"] ?? array() as $storyelement)
|
||||
{
|
||||
$storyboards[] = $beatmapset["path"] . "/" . $storyelement;
|
||||
$path = $beatmapset["path"] . "/" . $storyelement;
|
||||
if (file_exists($path)) $storyboards[] = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -372,9 +384,10 @@ class osu_library
|
||||
{
|
||||
foreach($beatmapset["difficulties"] as $beatmap)
|
||||
{
|
||||
if (!empty($beatmap["audio"]))
|
||||
if (!empty($beatmap["General"]["AudioFilename"]))
|
||||
{
|
||||
$audiofiles[] = $beatmapset["path"] . "/" . $beatmap["audio"];
|
||||
$path = $beatmapset["path"] . "/" . $beatmap["General"]["AudioFilename"];
|
||||
if (file_exists($path)) $audiofiles[] = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user