diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-03-24 17:31:21 +0100 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-03-24 17:31:21 +0100 |
commit | 7fa8b2eef7795aeb770bd3679bfbd30438388576 (patch) | |
tree | f0b352862edd76ce500dea2126d7a7993879b670 /apps/files_trashbin | |
parent | ecbcfca98aff39857e3fac622a667b7696cb0087 (diff) | |
download | nextcloud-server-7fa8b2eef7795aeb770bd3679bfbd30438388576.tar.gz nextcloud-server-7fa8b2eef7795aeb770bd3679bfbd30438388576.zip |
Add a guard to check that trashbin folder is a folder
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/files_trashbin')
-rw-r--r-- | apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php b/apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php index 578d08291a6..0aa41c1954f 100644 --- a/apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php +++ b/apps/files_trashbin/lib/UserMigration/TrashbinMigrator.php @@ -27,8 +27,10 @@ declare(strict_types=1); namespace OCA\Files_Trashbin\UserMigration; use OCA\Files_Trashbin\AppInfo\Application; +use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; +use OCP\IDBConnection; use OCP\IUser; use OCP\UserMigration\IExportDestination; use OCP\UserMigration\IImportSource; @@ -36,7 +38,6 @@ use OCP\UserMigration\IMigrator; use OCP\UserMigration\TMigratorBasicVersionHandling; use OCP\UserMigration\UserMigrationException; use Symfony\Component\Console\Output\OutputInterface; -use OCP\IDBConnection; class TrashbinMigrator implements IMigrator { @@ -67,6 +68,9 @@ class TrashbinMigrator implements IMigrator { try { $trashbinFolder = $this->root->get('/'.$uid.'/files_trashbin'); + if (!$trashbinFolder instanceof Folder) { + throw new UserMigrationException('Could not export trashbin, /'.$uid.'/files_trashbin is not a folder'); + } $output->writeln("Exporting trashbin files…"); if ($exportDestination->copyFolder($trashbinFolder, static::PATH_FILES_FOLDER) === false) { throw new UserMigrationException("Could not export trashbin."); @@ -96,6 +100,9 @@ class TrashbinMigrator implements IMigrator { if ($importSource->pathExists(static::PATH_FILES_FOLDER)) { try { $trashbinFolder = $this->root->get('/'.$uid.'/files_trashbin'); + if (!$trashbinFolder instanceof Folder) { + throw new UserMigrationException('Could not import trashbin, /'.$uid.'/files_trashbin is not a folder'); + } } catch (NotFoundException $e) { $trashbinFolder = $this->root->newFolder('/'.$uid.'/files_trashbin'); } |