summaryrefslogtreecommitdiffstats
path: root/apps/files/lib/Command
diff options
context:
space:
mode:
authorImmanuel Pasanec <immanuel.pasanec@compaso.de>2021-08-27 17:55:37 +0200
committerVincent Petry <vincent@nextcloud.com>2021-08-27 17:55:58 +0200
commit1f42657bb9ea76353fbc02ee100cff5755b6384d (patch)
tree5fa199e0effec6a78149f51a0f2ed74e3b669896 /apps/files/lib/Command
parent95662a1070e835cecba9e7478911e80487c9e4df (diff)
downloadnextcloud-server-1f42657bb9ea76353fbc02ee100cff5755b6384d.tar.gz
nextcloud-server-1f42657bb9ea76353fbc02ee100cff5755b6384d.zip
Added support for transfering incoming file shares.
- new option --transfer-incoming-shares=1 | 0 - new config.php option 'transfer-incoming-shares' => true | false The command line option overrules the config.php option. Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Diffstat (limited to 'apps/files/lib/Command')
-rw-r--r--apps/files/lib/Command/TransferOwnership.php43
1 files changed, 40 insertions, 3 deletions
diff --git a/apps/files/lib/Command/TransferOwnership.php b/apps/files/lib/Command/TransferOwnership.php
index 71853d632e7..50aa0b21a5f 100644
--- a/apps/files/lib/Command/TransferOwnership.php
+++ b/apps/files/lib/Command/TransferOwnership.php
@@ -31,12 +31,14 @@ declare(strict_types=1);
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
+
namespace OCA\Files\Command;
use OCA\Files\Exception\TransferOwnershipException;
use OCA\Files\Service\OwnershipTransferService;
use OCP\IUser;
use OCP\IUserManager;
+use OCP\IConfig;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@@ -51,17 +53,22 @@ class TransferOwnership extends Command {
/** @var OwnershipTransferService */
private $transferService;
+ /** @var IConfig */
+ private $config;
+
public function __construct(IUserManager $userManager,
- OwnershipTransferService $transferService) {
+ OwnershipTransferService $transferService,
+ IConfig $config) {
parent::__construct();
$this->userManager = $userManager;
$this->transferService = $transferService;
+ $this->config = $config;
}
protected function configure() {
$this
->setName('files:transfer-ownership')
- ->setDescription('All files and folders are moved to another user - shares are moved as well.')
+ ->setDescription('All files and folders are moved to another user - outgoing shares and incoming user file shares (optionally) are moved as well.')
->addArgument(
'source-user',
InputArgument::REQUIRED,
@@ -83,6 +90,12 @@ class TransferOwnership extends Command {
null,
InputOption::VALUE_NONE,
'move data from source user to root directory of destination user, which must be empty'
+ )->addOption(
+ 'transfer-incoming-shares',
+ null,
+ InputOption::VALUE_OPTIONAL,
+ 'transfer incoming user file shares to destination user. Usage: --transfer-incoming-shares=1 (value required)',
+ '2'
);
}
@@ -111,12 +124,36 @@ class TransferOwnership extends Command {
}
try {
+ $includeIncomingArgument = $input->getOption('transfer-incoming-shares');
+
+ switch ($includeIncomingArgument) {
+ case '0':
+ $includeIncoming = false;
+ break;
+ case '1':
+ $includeIncoming = true;
+ break;
+ case '2':
+ $includeIncoming = $this->config->getSystemValue('transferIncomingShares', false);
+ if (gettype($includeIncoming) !== 'boolean') {
+ $output->writeln("<error> config.php: 'transfer-incoming-shares': wrong usage. Transfer aborted.</error>");
+ return 1;
+ }
+ break;
+ default:
+ $output->writeln("<error>Option --transfer-incoming-shares: wrong usage. Transfer aborted.</error>");
+ return 1;
+ break;
+ }
+
$this->transferService->transfer(
$sourceUserObject,
$destinationUserObject,
ltrim($input->getOption('path'), '/'),
$output,
- $input->getOption('move') === true
+ $input->getOption('move') === true,
+ false,
+ $includeIncoming
);
} catch (TransferOwnershipException $e) {
$output->writeln("<error>" . $e->getMessage() . "</error>");