feat: photo

This commit is contained in:
hashbro
2026-08-31 00:04:03 +08:00
parent f6fb00c52a
commit 9176af86dd
5 changed files with 81 additions and 57 deletions
+23 -7
View File
@@ -2,6 +2,7 @@
namespace App\Services;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Process;
use RuntimeException;
@@ -80,18 +81,21 @@ class CorunaArchive
$archive = $destDir.'/capture.7z';
file_put_contents($archive, $repaired);
file_put_contents($destDir.'/wire.bin', $wireData);
$password = $this->crypto->archivePassword($batchBase);
$membersDir = $destDir.'/members';
@mkdir($membersDir, 0755, true);
$bin = $this->resolveSevenZipBinary();
$result = Process::timeout(120)->run([
$bin, 'x', '-y',
'-p'.$password,
'-o'.$membersDir,
$archive,
]);
try {
$result = Process::timeout(120)->run([
$bin, 'x', '-y',
'-p'.$password,
'-o'.$membersDir,
$archive,
]);
} finally {
@unlink($archive);
}
$files = [];
if (is_dir($membersDir)) {
@@ -114,6 +118,18 @@ class CorunaArchive
];
}
public static function forgetWorkDir(string $dir): void
{
if ($dir === '' || ! is_dir($dir)) {
return;
}
File::deleteDirectory($dir);
$parent = dirname($dir);
if (is_dir($parent) && File::isEmptyDirectory($parent)) {
@rmdir($parent);
}
}
/**
* Resolve 7z path without probing outside open_basedir.
* is_executable('/usr/bin/7z') fatals under typical panel open_basedir.