Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions apps/files/command/transferownership.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use OC\Files\View;
use OCP\Files\FileInfo;
use OCP\Files\Mount\IMountManager;
use OCP\IUser;
use OCP\IUserManager;
use OCP\Share\IManager;
use OCP\Share\IShare;
Expand Down Expand Up @@ -92,15 +93,21 @@ protected function configure() {
protected function execute(InputInterface $input, OutputInterface $output) {
$this->sourceUser = $input->getArgument('source-user');
$this->destinationUser = $input->getArgument('destination-user');
if (!$this->userManager->userExists($this->sourceUser)) {
$source = $this->userManager->get($this->sourceUser);
$destination = $this->userManager->get($this->destinationUser);

if (!$source instanceof IUser) {
$output->writeln("<error>Unknown source user $this->sourceUser</error>");
return;
}
if (!$this->userManager->userExists($this->destinationUser)) {
if (!$destination instanceof IUser) {
$output->writeln("<error>Unknown destination user $this->destinationUser</error>");
return;
}


$this->sourceUser = $source->getUID();
$this->destinationUser = $destination->getUID();

// target user has to be ready
if (!\OC::$server->getEncryptionManager()->isReadyForUser($this->destinationUser)) {
$output->writeln("<error>The target user is not ready to accept files. The user has at least to be logged in once.</error>");
Expand Down
10 changes: 10 additions & 0 deletions lib/private/user/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ protected function getUserObject($uid, $backend, $cacheUser = true) {
return $this->cachedUsers[$uid];
}

if (method_exists($backend, 'loginName2UserName')) {
$loginName = $backend->loginName2UserName($uid);
if ($loginName !== false) {
$uid = $loginName;
}
if (isset($this->cachedUsers[$uid])) {
return $this->cachedUsers[$uid];
}
}

$user = new User($uid, $backend, $this, $this->config);
if ($cacheUser) {
$this->cachedUsers[$uid] = $user;
Expand Down