mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
feat(files): add --use-user-id option to transfer-ownership command
Signed-off-by: Cristian Scheid <cristianscheid@gmail.com>
This commit is contained in:
parent
74351255db
commit
40d3118751
2 changed files with 14 additions and 1 deletions
|
|
@ -76,6 +76,12 @@ class TransferOwnership extends Command {
|
|||
null,
|
||||
InputOption::VALUE_NONE,
|
||||
'don\'t ask for confirmation for transferring external storages',
|
||||
)
|
||||
->addOption(
|
||||
'use-user-id',
|
||||
null,
|
||||
InputOption::VALUE_NONE,
|
||||
'use user ID instead of display name in the transferred folder name',
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -137,6 +143,7 @@ class TransferOwnership extends Command {
|
|||
$input->getOption('move') === true,
|
||||
false,
|
||||
$includeExternalStorage,
|
||||
$input->getOption('use-user-id') === true,
|
||||
);
|
||||
} catch (TransferOwnershipException $e) {
|
||||
$output->writeln('<error>' . $e->getMessage() . '</error>');
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ class OwnershipTransferService {
|
|||
bool $move = false,
|
||||
bool $firstLogin = false,
|
||||
bool $includeExternalStorage = false,
|
||||
bool $useUserId = false,
|
||||
): void {
|
||||
$output = $output ?? new NullOutput();
|
||||
$sourceUid = $sourceUser->getUID();
|
||||
|
|
@ -104,7 +105,12 @@ class OwnershipTransferService {
|
|||
$l = $this->l10nFactory->get('files', $this->l10nFactory->getUserLanguage($destinationUser));
|
||||
$date = date('Y-m-d H-i-s');
|
||||
|
||||
$cleanUserName = $this->sanitizeFolderName($sourceUser->getDisplayName()) ?: $sourceUid;
|
||||
if ($useUserId) {
|
||||
$cleanUserName = $sourceUid;
|
||||
} else {
|
||||
$cleanUserName = $this->sanitizeFolderName($sourceUser->getDisplayName()) ?: $sourceUid;
|
||||
}
|
||||
|
||||
$finalTarget = "$destinationUid/files/" . $this->sanitizeFolderName($l->t('Transferred from %1$s on %2$s', [$cleanUserName, $date]));
|
||||
try {
|
||||
$view->verifyPath(dirname($finalTarget), basename($finalTarget));
|
||||
|
|
|
|||
Loading…
Reference in a new issue