diff --git a/lib/Command/Export.php b/lib/Command/Export.php
index d3676b98..e16fc8b8 100644
--- a/lib/Command/Export.php
+++ b/lib/Command/Export.php
@@ -15,7 +15,6 @@
use OCP\IUser;
use OCP\IUserManager;
use OCP\UserMigration\IMigrator;
-use Symfony\Component\Console\Command\HelpCommand;
use Symfony\Component\Console\Formatter\WrappableOutputFormatterInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@@ -58,13 +57,14 @@ protected function configure(): void {
)
->addArgument(
'user',
- InputArgument::OPTIONAL,
+ InputArgument::REQUIRED,
'user to export',
)
->addArgument(
'folder',
InputArgument::OPTIONAL,
'local folder to export into',
+ getcwd()
);
}
@@ -73,25 +73,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
/** @var WrappableOutputFormatterInterface $formatter */
$formatter = $io->getFormatter();
- // Filter for only explicitly passed arguments
- $args = array_filter(
- $input->getArguments(),
- fn (?string $value, string $arg) => $arg === 'command' ? false : !empty($value),
- ARRAY_FILTER_USE_BOTH,
- );
- // Filter for only explicitly passed options
- $options = array_filter(
- $input->getOptions(),
- fn ($value) => $value !== false,
- );
-
- // Show help if no arguments or options are passed
- if (empty($args) && empty($options)) {
- $help = new HelpCommand();
- $help->setCommand($this);
- return $help->run($input, $io);
- }
-
$migrators = $this->migrationService->getMigrators();
$list = $input->getOption('list');
@@ -153,10 +134,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
$uid = $input->getArgument('user');
- if (empty($uid)) {
- $io->error('Missing user argument');
- return 1;
- }
$user = $this->userManager->get($uid);
if (!$user instanceof IUser) {
@@ -165,14 +142,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
$folder = $input->getArgument('folder');
- if (empty($folder)) {
- $io->error('Missing folder argument');
- return 1;
- }
try {
if (!is_writable($folder)) {
- $io->error('The target folder must exist and be writable by the web server user');
+ $io->error('The target folder (' . $folder . ') must exist and be writable by the web server user');
return 1;
}
$folder = realpath($folder);
diff --git a/lib/Service/UserMigrationService.php b/lib/Service/UserMigrationService.php
index 5d1ae975..3bee07c5 100644
--- a/lib/Service/UserMigrationService.php
+++ b/lib/Service/UserMigrationService.php
@@ -10,7 +10,6 @@
namespace OCA\UserMigration\Service;
use OC\AppFramework\Bootstrap\Coordinator;
-use OC\Cache\CappedMemoryCache;
use OCA\UserMigration\BackgroundJob\UserExportJob;
use OCA\UserMigration\BackgroundJob\UserImportJob;
use OCA\UserMigration\Db\UserExport;
@@ -21,9 +20,11 @@
use OCA\UserMigration\NotExportableException;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\BackgroundJob\IJobList;
+use OCP\Cache\CappedMemoryCache;
use OCP\Files\File;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
+use OCP\IAppConfig;
use OCP\IConfig;
use OCP\IUser;
use OCP\IUserManager;
@@ -42,23 +43,6 @@
class UserMigrationService {
use TMigratorBasicVersionHandling;
- protected IRootFolder $root;
-
- protected IConfig $config;
-
- protected IUserManager $userManager;
-
- protected ContainerInterface $container;
-
- // Allow use of the private Coordinator class here to get and run registered migrators
- protected Coordinator $coordinator;
-
- protected UserExportMapper $exportMapper;
-
- protected UserImportMapper $importMapper;
-
- protected IJobList $jobList;
-
protected CappedMemoryCache $internalCache;
protected const ENTITY_JOB_MAP = [
@@ -66,24 +50,18 @@ class UserMigrationService {
UserImport::class => UserImportJob::class,
];
+ // Allow use of the private Coordinator class here to get and run registered migrators
public function __construct(
- IRootFolder $rootFolder,
- IConfig $config,
- IUserManager $userManager,
- ContainerInterface $container,
- Coordinator $coordinator,
- UserExportMapper $exportMapper,
- UserImportMapper $importMapper,
- IJobList $jobList,
+ private IRootFolder $rootFolder,
+ private IConfig $config,
+ private IUserManager $userManager,
+ private ContainerInterface $container,
+ private Coordinator $coordinator,
+ private UserExportMapper $exportMapper,
+ private UserImportMapper $importMapper,
+ private IJobList $jobList,
+ private IAppConfig $appConfig,
) {
- $this->root = $rootFolder;
- $this->config = $config;
- $this->userManager = $userManager;
- $this->container = $container;
- $this->coordinator = $coordinator;
- $this->exportMapper = $exportMapper;
- $this->importMapper = $importMapper;
- $this->jobList = $jobList;
$this->internalCache = new CappedMemoryCache();
$this->mandatory = true;
@@ -132,7 +110,7 @@ public function estimateExportSize(IUser $user, ?array $filteredMigratorList = n
*/
public function checkExportability(IUser $user, ?array $filteredMigratorList = null): void {
try {
- $userFolder = $this->root->getUserFolder($user->getUID());
+ $userFolder = $this->rootFolder->getUserFolder($user->getUID());
$freeSpace = ceil($userFolder->getFreeSpace() / 1024);
} catch (Throwable $e) {
throw new NotExportableException('Error calculating amount of free storage space available');
@@ -299,7 +277,7 @@ protected function exportVersions(string $uid,
$versions = array_merge(
['core' => $this->config->getSystemValue('version')],
- \OC_App::getAppVersions()
+ $this->appConfig->getAppInstalledVersions()
);
try {
diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml
index 90237ba4..e8e431d3 100644
--- a/tests/psalm-baseline.xml
+++ b/tests/psalm-baseline.xml
@@ -5,9 +5,4 @@
-
-
-
-
-