Skip to content

Commit 9dfa58b

Browse files
committed
Skip import of current calendar on error
Signed-off-by: Christopher Ng <chrng8@gmail.com>
1 parent c1215f5 commit 9dfa58b

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

apps/dav/lib/UserMigration/CalendarMigrator.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ private function initCalendarObject(): VCalendar {
318318
return $vCalendarObject;
319319
}
320320

321+
/**
322+
* @throws InvalidCalendarException
323+
*/
321324
private function importCalendarObject(int $calendarId, VCalendar $vCalendarObject, OutputInterface $output): void {
322325
try {
323326
$this->calDavBackend->createCalendarObject(
@@ -330,12 +333,10 @@ private function importCalendarObject(int $calendarId, VCalendar $vCalendarObjec
330333
// Rollback creation of calendar on error
331334
$output->writeln('Error creating calendar object, rolling back creation of calendar…');
332335
$this->calDavBackend->deleteCalendar($calendarId, true);
336+
throw new InvalidCalendarException();
333337
}
334338
}
335339

336-
/**
337-
* @throws CalendarMigratorException
338-
*/
339340
private function importCalendar(IUser $user, string $filename, string $initialCalendarUri, VCalendar $vCalendar, OutputInterface $output): void {
340341
$principalUri = $this->getPrincipalUri($user);
341342
$calendarUri = $this->getUniqueCalendarUri($user, $initialCalendarUri);
@@ -446,13 +447,18 @@ public function import(IUser $user, IImportSource $importSource, OutputInterface
446447
}
447448
[$initialCalendarUri, $suffix] = $splitFilename;
448449

449-
$this->importCalendar(
450-
$user,
451-
$filename,
452-
$initialCalendarUri,
453-
$vCalendar,
454-
$output,
455-
);
450+
try {
451+
$this->importCalendar(
452+
$user,
453+
$filename,
454+
$initialCalendarUri,
455+
$vCalendar,
456+
$output,
457+
);
458+
} catch (InvalidCalendarException $e) {
459+
// Skip import of current calendar on error
460+
continue;
461+
}
456462

457463
$vCalendar->destroy();
458464
}

0 commit comments

Comments
 (0)