From edaa4363453351641356058a63495f85cda77e02 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 17 Jan 2024 17:47:01 +0100 Subject: add key location to info:file output Signed-off-by: Robin Appelman --- core/Command/Info/File.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'core/Command') diff --git a/core/Command/Info/File.php b/core/Command/Info/File.php index d62feeb5a17..4afda280370 100644 --- a/core/Command/Info/File.php +++ b/core/Command/Info/File.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace OC\Core\Command\Info; use OC\Files\ObjectStore\ObjectStoreStorage; +use OC\Files\View; use OCA\Files_External\Config\ExternalMountPoint; use OCA\GroupFolders\Mount\GroupMountPoint; use OCP\Files\Folder; @@ -23,13 +24,16 @@ use Symfony\Component\Console\Output\OutputInterface; class File extends Command { private IL10N $l10n; + private View $rootView; public function __construct( IFactory $l10nFactory, private FileUtils $fileUtils, + private \OC\Encryption\Util $encryptionUtil ) { $this->l10n = $l10nFactory->get("core"); parent::__construct(); + $this->rootView = new View(); } protected function configure(): void { @@ -54,6 +58,14 @@ class File extends Command { $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()) { + $keyPath = $this->encryptionUtil->getFileKeyDir('', $node->getPath()); + if ($this->rootView->file_exists($keyPath)) { + $output->writeln(" encryption key at: " . $keyPath); + } else { + $output->writeln(" encryption key not found should be located at: " . $keyPath); + } + } $output->writeln(" size: " . Util::humanFileSize($node->getSize())); $output->writeln(" etag: " . $node->getEtag()); if ($node instanceof Folder) { -- cgit v1.2.3