mirror of
https://github.com/nextcloud/server.git
synced 2024-08-23 05:56:02 +02:00
fix(dav): Remove usage of indirect thecodingmachine/safe dependency
Signed-off-by: Christopher Ng <chrng8@gmail.com>
This commit is contained in:
parent
c5d82409b4
commit
5281623329
@ -26,7 +26,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace OCA\DAV\UserMigration;
|
||||
|
||||
use function Safe\substr;
|
||||
use function substr;
|
||||
use OCA\DAV\AppInfo\Application;
|
||||
use OCA\DAV\CalDAV\CalDavBackend;
|
||||
use OCA\DAV\CalDAV\ICSExportPlugin\ICSExportPlugin;
|
||||
@ -50,7 +50,6 @@ use Sabre\VObject\Component\VTimeZone;
|
||||
use Sabre\VObject\Property\ICalendar\DateTime;
|
||||
use Sabre\VObject\Reader as VObjectReader;
|
||||
use Sabre\VObject\UUIDUtil;
|
||||
use Safe\Exceptions\StringsException;
|
||||
use Symfony\Component\Console\Output\NullOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Throwable;
|
||||
@ -185,12 +184,13 @@ class CalendarMigrator implements IMigrator, ISizeEstimationMigrator {
|
||||
|
||||
private function getUniqueCalendarUri(IUser $user, string $initialCalendarUri): string {
|
||||
$principalUri = $this->getPrincipalUri($user);
|
||||
try {
|
||||
$initialCalendarUri = substr($initialCalendarUri, 0, strlen(CalendarMigrator::MIGRATED_URI_PREFIX)) === CalendarMigrator::MIGRATED_URI_PREFIX
|
||||
? $initialCalendarUri
|
||||
: CalendarMigrator::MIGRATED_URI_PREFIX . $initialCalendarUri;
|
||||
} catch (StringsException $e) {
|
||||
throw new CalendarMigratorException('Failed to get unique calendar URI', 0, $e);
|
||||
|
||||
$initialCalendarUri = substr($initialCalendarUri, 0, strlen(CalendarMigrator::MIGRATED_URI_PREFIX)) === CalendarMigrator::MIGRATED_URI_PREFIX
|
||||
? $initialCalendarUri
|
||||
: CalendarMigrator::MIGRATED_URI_PREFIX . $initialCalendarUri;
|
||||
|
||||
if ($initialCalendarUri === '') {
|
||||
throw new CalendarMigratorException('Failed to get unique calendar URI');
|
||||
}
|
||||
|
||||
$existingCalendarUris = array_map(
|
||||
|
@ -26,8 +26,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace OCA\DAV\UserMigration;
|
||||
|
||||
use function Safe\sort;
|
||||
use function Safe\substr;
|
||||
use function sort;
|
||||
use function substr;
|
||||
use OCA\DAV\AppInfo\Application;
|
||||
use OCA\DAV\CardDAV\CardDavBackend;
|
||||
use OCA\DAV\CardDAV\Plugin as CardDAVPlugin;
|
||||
@ -46,8 +46,6 @@ use Sabre\VObject\Parser\Parser as VObjectParser;
|
||||
use Sabre\VObject\Reader as VObjectReader;
|
||||
use Sabre\VObject\Splitter\VCard as VCardSplitter;
|
||||
use Sabre\VObject\UUIDUtil;
|
||||
use Safe\Exceptions\ArrayException;
|
||||
use Safe\Exceptions\StringsException;
|
||||
use Symfony\Component\Console\Output\NullOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Throwable;
|
||||
@ -165,12 +163,12 @@ class ContactsMigrator implements IMigrator, ISizeEstimationMigrator {
|
||||
private function getUniqueAddressBookUri(IUser $user, string $initialAddressBookUri): string {
|
||||
$principalUri = $this->getPrincipalUri($user);
|
||||
|
||||
try {
|
||||
$initialAddressBookUri = substr($initialAddressBookUri, 0, strlen(ContactsMigrator::MIGRATED_URI_PREFIX)) === ContactsMigrator::MIGRATED_URI_PREFIX
|
||||
? $initialAddressBookUri
|
||||
: ContactsMigrator::MIGRATED_URI_PREFIX . $initialAddressBookUri;
|
||||
} catch (StringsException $e) {
|
||||
throw new ContactsMigratorException('Failed to get unique address book URI', 0, $e);
|
||||
$initialAddressBookUri = substr($initialAddressBookUri, 0, strlen(ContactsMigrator::MIGRATED_URI_PREFIX)) === ContactsMigrator::MIGRATED_URI_PREFIX
|
||||
? $initialAddressBookUri
|
||||
: ContactsMigrator::MIGRATED_URI_PREFIX . $initialAddressBookUri;
|
||||
|
||||
if ($initialAddressBookUri === '') {
|
||||
throw new ContactsMigratorException('Failed to get unique address book URI');
|
||||
}
|
||||
|
||||
$existingAddressBookUris = array_map(
|
||||
@ -303,11 +301,10 @@ class ContactsMigrator implements IMigrator, ISizeEstimationMigrator {
|
||||
fn (string $filename) => pathinfo($filename, PATHINFO_EXTENSION) === ContactsMigrator::METADATA_EXT,
|
||||
);
|
||||
|
||||
try {
|
||||
sort($addressBookImports);
|
||||
sort($metadataImports);
|
||||
} catch (ArrayException $e) {
|
||||
throw new ContactsMigratorException('Failed to sort address book files in ' . ContactsMigrator::PATH_ROOT, 0, $e);
|
||||
$addressBookSort = sort($addressBookImports);
|
||||
$metadataSort = sort($metadataImports);
|
||||
if ($addressBookSort === false || $metadataSort === false) {
|
||||
throw new ContactsMigratorException('Failed to sort address book files in ' . ContactsMigrator::PATH_ROOT);
|
||||
}
|
||||
|
||||
if (count($addressBookImports) !== count($metadataImports)) {
|
||||
|
Loading…
Reference in New Issue
Block a user