From 309cdf3f09a5b4926960c8d7ce884be9cc817b57 Mon Sep 17 00:00:00 2001 From: Haylan Date: Mon, 14 Sep 2026 22:00:26 +0200 Subject: [PATCH] feat(dump): list dumps stored in the plugin filesystem --- src/Service/DumpLister.php | 48 +++++++++++++++++++ .../Exception/DumpNotFoundException.php | 13 +++++ src/Struct/DumpFile.php | 29 +++++++++++ 3 files changed, 90 insertions(+) create mode 100644 src/Service/DumpLister.php create mode 100644 src/Service/Exception/DumpNotFoundException.php create mode 100644 src/Struct/DumpFile.php diff --git a/src/Service/DumpLister.php b/src/Service/DumpLister.php new file mode 100644 index 0000000..a6c8c4f --- /dev/null +++ b/src/Service/DumpLister.php @@ -0,0 +1,48 @@ +aeonDumpManagerFilesystemPrivate->listContents(self::DUMP_DIRECTORY) as $item) { + if (!$item->isFile()) { + continue; + } + + $filename = basename($item->path()); + $datetime = $this->filenameParser->parse($filename); + if ($datetime === null) { + continue; + } + + $dumps[] = new DumpFile($filename, $datetime, $item->fileSize()); + } + + usort($dumps, static fn (DumpFile $a, DumpFile $b) => $b->datetime <=> $a->datetime ?: $b->filename <=> $a->filename); + + return $dumps; + } + + public static function path(string $filename): string + { + return self::DUMP_DIRECTORY . '/' . $filename; + } +} diff --git a/src/Service/Exception/DumpNotFoundException.php b/src/Service/Exception/DumpNotFoundException.php new file mode 100644 index 0000000..2f200e7 --- /dev/null +++ b/src/Service/Exception/DumpNotFoundException.php @@ -0,0 +1,13 @@ + $this->filename, + 'datetime' => $this->datetime->format(DATE_ATOM), + 'sizeBytes' => $this->sizeBytes, + ]; + } +}