DataFingerprint.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OC\Core\Command\Maintenance;
  8. use OCP\AppFramework\Utility\ITimeFactory;
  9. use OCP\IConfig;
  10. use Symfony\Component\Console\Command\Command;
  11. use Symfony\Component\Console\Input\InputInterface;
  12. use Symfony\Component\Console\Output\OutputInterface;
  13. class DataFingerprint extends Command {
  14. public function __construct(
  15. protected IConfig $config,
  16. protected ITimeFactory $timeFactory,
  17. ) {
  18. parent::__construct();
  19. }
  20. protected function configure() {
  21. $this
  22. ->setName('maintenance:data-fingerprint')
  23. ->setDescription('update the systems data-fingerprint after a backup is restored');
  24. }
  25. protected function execute(InputInterface $input, OutputInterface $output): int {
  26. $fingerPrint = md5($this->timeFactory->getTime());
  27. $this->config->setSystemValue('data-fingerprint', $fingerPrint);
  28. $output->writeln('<info>Updated data-fingerprint to ' . $fingerPrint . '</info>');
  29. return 0;
  30. }
  31. }