owncloud / data_exporter

Export/Import for ownCloud user data
GNU General Public License v2.0
7 stars 5 forks source link

Catch NotFoundExceptions in ShareExtractor #95

Open micbar opened 5 years ago

micbar commented 5 years ago

Problem

NotFoundExceptions in the ShareExtractor are not visible in the CLI because the the exception has NULL as a message.

It only shows up in the CLI as an empty line.

Solution

Catch the NotFoundExceptions and provide a meaningful message which enables the admin to find the cause of the problem.

+                               try {
+                                       $shareModel->setPath($userFolder->getRelativePath($share->getNode()->getPath()))
+                                               ->setShareType(Share::SHARETYPE_USER)
+                                               ->setOwner($share->getShareOwner())
+                                               ->setSharedBy($share->getSharedBy())
+                                               ->setSharedWith($share->getSharedWith())
+                                               ->setPermissions($share->getPermissions());
+                                       // the rest of the model attributes doesn't make sense with local shares
+                                       $this->streamHelper->writelnToStream(
+                                               $this->streamFile,
+                                               $shareModel
+                                       );
+                               } catch (NotFoundException $exception) {
+                                       $shareId = $share->getId();
+                                       throw new ImportException("Could not find Node for shareId $shareId");
+                               }