fileUtils->getNode($file); if (!$node) { $output->writeln("file $file not found"); return ExitCode::Failure; } $deleteConfirmed = $force; if (!$deleteConfirmed) { $storage = $node->getStorage(); if (!$inputIsId && $storage->instanceOfStorage(SharedStorage::class) && $node->getInternalPath() === '') { /** @var SharedStorage $storage */ [,$user] = explode('/', $file, 3); if ($input->confirm("$file in a shared file, do you want to unshare the file from $user instead of deleting the source file? [Y/n] ", true)) { $storage->unshareStorage(); return ExitCode::Success; } else { $node = $storage->getShare()->getNode(); $output->writeln(''); } } $filesByUsers = $this->fileUtils->getFilesByUser($node); if (count($filesByUsers) > 1) { $output->writeln('Warning: the provided file is accessible by more than one user'); $output->writeln(' all of the following users will lose access to the file when deleted:'); $output->writeln(''); foreach ($filesByUsers as $user => $filesByUser) { $output->writeln($user . ':'); foreach ($filesByUser as $userFile) { $output->writeln(' - ' . $userFile->getPath()); } } $output->writeln(''); } if ($node instanceof Folder) { $maybeContents = " and all it's contents"; } else { $maybeContents = ''; } $deleteConfirmed = $input->confirm('Delete ' . $node->getPath() . $maybeContents . '? [y/N] ', false); } if ($deleteConfirmed) { if ($node->isDeletable()) { if ($skipTrash && $this->trashManager) { $this->trashManager->pauseTrash(); } $node->delete(); } else { $output->writeln('File cannot be deleted, insufficient permissions.'); } } return ExitCode::Success; } }