diff options
author | Christopher Ng <chrng8@gmail.com> | 2022-04-20 04:43:30 +0000 |
---|---|---|
committer | Christopher Ng <chrng8@gmail.com> | 2022-04-20 04:43:30 +0000 |
commit | e670f692ccc9815ff892753de8b0370dc8e777f9 (patch) | |
tree | c6ff23ecfd1e5751407cf30abba39e7d3a7aa0fd /apps/dav/lib/UserMigration | |
parent | 1ea252fad5c6a57baf24c1483800a594ec8ba705 (diff) | |
download | nextcloud-server-e670f692ccc9815ff892753de8b0370dc8e777f9.tar.gz nextcloud-server-e670f692ccc9815ff892753de8b0370dc8e777f9.zip |
Fix export of shared calendars
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps/dav/lib/UserMigration')
-rw-r--r-- | apps/dav/lib/UserMigration/CalendarMigrator.php | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/apps/dav/lib/UserMigration/CalendarMigrator.php b/apps/dav/lib/UserMigration/CalendarMigrator.php index d94e3ec109e..015ce6faa86 100644 --- a/apps/dav/lib/UserMigration/CalendarMigrator.php +++ b/apps/dav/lib/UserMigration/CalendarMigrator.php @@ -108,14 +108,7 @@ class CalendarMigrator implements IMigrator { */ private function getCalendarExportData(IUser $user, ICalendar $calendar, OutputInterface $output): array { $userId = $user->getUID(); - $calendarId = $calendar->getKey(); - $calendarInfo = $this->calDavBackend->getCalendarById($calendarId); - - if (empty($calendarInfo)) { - throw new CalendarMigratorException("Invalid info for calendar ID $calendarId"); - } - - $uri = $calendarInfo['uri']; + $uri = $calendar->getUri(); $path = CalDAVPlugin::CALENDAR_ROOT . "/$userId/$uri"; /** @@ -227,12 +220,12 @@ class CalendarMigrator implements IMigrator { try { /** - * @var string $name - * @var VCalendar $vCalendar - */ + * @var string $name + * @var VCalendar $vCalendar + */ foreach ($calendarExports as ['name' => $name, 'vCalendar' => $vCalendar]) { - // Set filename to sanitized calendar name appended with the date - $filename = preg_replace('/[^a-zA-Z0-9-_ ]/um', '', $name) . '_' . date('Y-m-d') . CalendarMigrator::FILENAME_EXT; + // Set filename to sanitized calendar name + $filename = preg_replace('/[^a-z0-9-_]/iu', '', $name) . CalendarMigrator::FILENAME_EXT; $exportPath = CalendarMigrator::EXPORT_ROOT . $filename; $exportDestination->addFileContents($exportPath, $vCalendar->serialize()); @@ -445,11 +438,11 @@ class CalendarMigrator implements IMigrator { throw new CalendarMigratorException("Invalid calendar data contained in \"$importPath\""); } - $splitFilename = explode('_', $filename, 2); + $splitFilename = explode('.', $filename, 2); if (count($splitFilename) !== 2) { - throw new CalendarMigratorException("Invalid filename \"$filename\", expected filename of the format \"<calendar_name>_YYYY-MM-DD" . CalendarMigrator::FILENAME_EXT . '"'); + throw new CalendarMigratorException("Invalid filename \"$filename\", expected filename of the format \"<calendar_name>" . CalendarMigrator::FILENAME_EXT . '"'); } - [$initialCalendarUri, $suffix] = $splitFilename; + [$initialCalendarUri, $ext] = $splitFilename; try { $this->importCalendar( |