Repacker implemented
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
require_once "libraries/utils.php";
|
||||
// todo: make it work correctly on mac & linux (case sensitivity on deletion)
|
||||
class optimizer
|
||||
{
|
||||
@@ -254,4 +255,31 @@ class optimizer
|
||||
if (file_exists($file)) unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
public static function repack(osu_library $library, string $key) : string
|
||||
{
|
||||
$path = $library->get_library()[$key]["path"] ?? "";
|
||||
if (!file_exists($path)) return "";
|
||||
|
||||
$name = "session/osz/" . basename($path) . ".osz";
|
||||
if (file_exists($name)) return $name;
|
||||
|
||||
$zip = new ZipArchive;
|
||||
|
||||
try
|
||||
{
|
||||
$zip->open($name, ZipArchive::CREATE);
|
||||
utils::recursive_zip_map($zip, $path, $path);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
finally
|
||||
{
|
||||
$zip->close();
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
+1
-12
@@ -17,7 +17,7 @@ class utils
|
||||
{
|
||||
if (is_dir($file))
|
||||
{
|
||||
recursive_zip_map($zip, $root, $file);
|
||||
self::recursive_zip_map($zip, $root, $file);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -26,15 +26,4 @@ class utils
|
||||
}
|
||||
}
|
||||
}
|
||||
// $folder = $my_db[$beatmap_id];
|
||||
// $name = basename($folder) . ".osz";
|
||||
|
||||
// echo "Zipping " . $name;
|
||||
|
||||
// $path = $collection_location . "/" . $name;
|
||||
// $zip = new ZipArchive;
|
||||
// $zip->open($path, ZipArchive::CREATE);
|
||||
// echo ".";
|
||||
|
||||
// recursive_zip_map($zip, $fol
|
||||
}
|
||||
Reference in New Issue
Block a user