From fffe826d90d9d17e47c9f7f37b91ab086e3aece8 Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Mon, 26 Aug 2024 19:28:44 +0200 Subject: [PATCH] feat: Improve encryption mode detection in occ info:file Signed-off-by: Louis Chemineau --- core/Command/Info/File.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/Command/Info/File.php b/core/Command/Info/File.php index 0a3006ac1d7b3..76fbd38712c2b 100644 --- a/core/Command/Info/File.php +++ b/core/Command/Info/File.php @@ -11,6 +11,7 @@ use OC\Files\View; use OCA\Files_External\Config\ExternalMountPoint; use OCA\GroupFolders\Mount\GroupMountPoint; +use OCP\Files\File as OCPFile; use OCP\Files\Folder; use OCP\Files\IHomeStorage; use OCP\Files\Mount\IMountPoint; @@ -61,8 +62,9 @@ public function execute(InputInterface $input, OutputInterface $output): int { $output->writeln(' fileid: ' . $node->getId()); $output->writeln(' mimetype: ' . $node->getMimetype()); $output->writeln(' modified: ' . (string)$this->l10n->l('datetime', $node->getMTime())); - $output->writeln(' ' . ($node->isEncrypted() ? 'encrypted' : 'not encrypted')); - if ($node->isEncrypted()) { + + if ($node instanceof OCPFile && $node->isEncrypted()) { + $output->writeln(' ' . 'server-side encrypted: yes'); $keyPath = $this->encryptionUtil->getFileKeyDir('', $node->getPath()); if ($this->rootView->file_exists($keyPath)) { $output->writeln(' encryption key at: ' . $keyPath); @@ -70,6 +72,11 @@ public function execute(InputInterface $input, OutputInterface $output): int { $output->writeln(' encryption key not found should be located at: ' . $keyPath); } } + + if ($node instanceof Folder && $node->isEncrypted() || $node instanceof OCPFile && $node->getParent()->isEncrypted()) { + $output->writeln(' ' . 'end-to-end encrypted: yes'); + } + $output->writeln(' size: ' . Util::humanFileSize($node->getSize())); $output->writeln(' etag: ' . $node->getEtag()); if ($node instanceof Folder) {