Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Skip instead of throwing on invalid calendar migration
Signed-off-by: Christopher Ng <[email protected]>
  • Loading branch information
Pytal authored and skjnldsv committed Feb 23, 2024
commit 07bf1298090075295535684ff9ecb601ac8237d9
14 changes: 10 additions & 4 deletions apps/dav/lib/UserMigration/CalendarMigrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ function (ICalendar $calendar) use ($user, $output) {
)));
}

/**
* @throws InvalidCalendarException
*/
private function getUniqueCalendarUri(IUser $user, string $initialCalendarUri): string {
$principalUri = $this->getPrincipalUri($user);

Expand All @@ -190,7 +193,7 @@ private function getUniqueCalendarUri(IUser $user, string $initialCalendarUri):
: CalendarMigrator::MIGRATED_URI_PREFIX . $initialCalendarUri;

if ($initialCalendarUri === '') {
throw new CalendarMigratorException('Failed to get unique calendar URI');
throw new InvalidCalendarException();
}

$existingCalendarUris = array_map(
Expand Down Expand Up @@ -457,17 +460,20 @@ public function import(IUser $user, IImportSource $importSource, OutputInterface
VObjectReader::OPTION_FORGIVING,
);
} catch (Throwable $e) {
throw new CalendarMigratorException("Failed to read file \"$importPath\"", 0, $e);
$output->writeln("Failed to read file \"$importPath\", skipping…");
continue;
}

$problems = $vCalendar->validate();
if (!empty($problems)) {
throw new CalendarMigratorException("Invalid calendar data contained in \"$importPath\"");
$output->writeln("Invalid calendar data contained in \"$importPath\", skipping…");
continue;
}

$splitFilename = explode('.', $filename, 2);
if (count($splitFilename) !== 2) {
throw new CalendarMigratorException("Invalid filename \"$filename\", expected filename of the format \"<calendar_name>" . CalendarMigrator::FILENAME_EXT . '"');
$output->writeln("Invalid filename \"$filename\", expected filename of the format \"<calendar_name>" . CalendarMigrator::FILENAME_EXT . '", skipping…');
continue;
}
[$initialCalendarUri, $ext] = $splitFilename;

Expand Down