|
26 | 26 |
|
27 | 27 | namespace OCA\DAV\UserMigration; |
28 | 28 |
|
29 | | -use function Safe\sort; |
30 | | -use function Safe\substr; |
| 29 | +use function sort; |
| 30 | +use function substr; |
31 | 31 | use OCA\DAV\AppInfo\Application; |
32 | 32 | use OCA\DAV\CardDAV\CardDavBackend; |
33 | 33 | use OCA\DAV\CardDAV\Plugin as CardDAVPlugin; |
|
46 | 46 | use Sabre\VObject\Reader as VObjectReader; |
47 | 47 | use Sabre\VObject\Splitter\VCard as VCardSplitter; |
48 | 48 | use Sabre\VObject\UUIDUtil; |
49 | | -use Safe\Exceptions\ArrayException; |
50 | | -use Safe\Exceptions\StringsException; |
51 | 49 | use Symfony\Component\Console\Output\NullOutput; |
52 | 50 | use Symfony\Component\Console\Output\OutputInterface; |
53 | 51 | use Throwable; |
@@ -165,12 +163,12 @@ function (array $addressBookInfo) use ($user, $output) { |
165 | 163 | private function getUniqueAddressBookUri(IUser $user, string $initialAddressBookUri): string { |
166 | 164 | $principalUri = $this->getPrincipalUri($user); |
167 | 165 |
|
168 | | - try { |
169 | | - $initialAddressBookUri = substr($initialAddressBookUri, 0, strlen(ContactsMigrator::MIGRATED_URI_PREFIX)) === ContactsMigrator::MIGRATED_URI_PREFIX |
170 | | - ? $initialAddressBookUri |
171 | | - : ContactsMigrator::MIGRATED_URI_PREFIX . $initialAddressBookUri; |
172 | | - } catch (StringsException $e) { |
173 | | - throw new ContactsMigratorException('Failed to get unique address book URI', 0, $e); |
| 166 | + $initialAddressBookUri = substr($initialAddressBookUri, 0, strlen(ContactsMigrator::MIGRATED_URI_PREFIX)) === ContactsMigrator::MIGRATED_URI_PREFIX |
| 167 | + ? $initialAddressBookUri |
| 168 | + : ContactsMigrator::MIGRATED_URI_PREFIX . $initialAddressBookUri; |
| 169 | + |
| 170 | + if ($initialAddressBookUri === '') { |
| 171 | + throw new ContactsMigratorException('Failed to get unique address book URI'); |
174 | 172 | } |
175 | 173 |
|
176 | 174 | $existingAddressBookUris = array_map( |
@@ -303,11 +301,10 @@ private function getAddressBookImports(array $importFiles): array { |
303 | 301 | fn (string $filename) => pathinfo($filename, PATHINFO_EXTENSION) === ContactsMigrator::METADATA_EXT, |
304 | 302 | ); |
305 | 303 |
|
306 | | - try { |
307 | | - sort($addressBookImports); |
308 | | - sort($metadataImports); |
309 | | - } catch (ArrayException $e) { |
310 | | - throw new ContactsMigratorException('Failed to sort address book files in ' . ContactsMigrator::PATH_ROOT, 0, $e); |
| 304 | + $addressBookSort = sort($addressBookImports); |
| 305 | + $metadataSort = sort($metadataImports); |
| 306 | + if ($addressBookSort === false || $metadataSort === false) { |
| 307 | + throw new ContactsMigratorException('Failed to sort address book files in ' . ContactsMigrator::PATH_ROOT); |
311 | 308 | } |
312 | 309 |
|
313 | 310 | if (count($addressBookImports) !== count($metadataImports)) { |
|
0 commit comments