aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/lib/Command/Object/ObjectUtil.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/lib/Command/Object/ObjectUtil.php')
-rw-r--r--apps/files/lib/Command/Object/ObjectUtil.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/apps/files/lib/Command/Object/ObjectUtil.php b/apps/files/lib/Command/Object/ObjectUtil.php
index b85591e8a32..e2b2e3bbfb8 100644
--- a/apps/files/lib/Command/Object/ObjectUtil.php
+++ b/apps/files/lib/Command/Object/ObjectUtil.php
@@ -12,6 +12,7 @@ use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Files\ObjectStore\IObjectStore;
use OCP\IConfig;
use OCP\IDBConnection;
+use OCP\Util;
use Symfony\Component\Console\Output\OutputInterface;
class ObjectUtil {
@@ -91,4 +92,24 @@ class ObjectUtil {
return $fileId;
}
+
+ public function formatObjects(\Iterator $objects, bool $humanOutput): \Iterator {
+ foreach ($objects as $object) {
+ yield $this->formatObject($object, $humanOutput);
+ }
+ }
+
+ public function formatObject(array $object, bool $humanOutput): array {
+ $row = array_merge([
+ 'urn' => $object['urn'],
+ ], ($object['metadata'] ?? []));
+
+ if ($humanOutput && isset($row['size'])) {
+ $row['size'] = Util::humanFileSize($row['size']);
+ }
+ if (isset($row['mtime'])) {
+ $row['mtime'] = $row['mtime']->format(\DateTimeImmutable::ATOM);
+ }
+ return $row;
+ }
}