]> source.dussan.org Git - nextcloud-server.git/commitdiff
Skip instead of throwing on invalid calendar migration
authorChristopher Ng <chrng8@gmail.com>
Wed, 18 May 2022 01:23:30 +0000 (01:23 +0000)
committerskjnldsv <skjnldsv@protonmail.com>
Fri, 23 Feb 2024 14:22:31 +0000 (15:22 +0100)
Signed-off-by: Christopher Ng <chrng8@gmail.com>
apps/dav/lib/UserMigration/CalendarMigrator.php

index 14ea4459435d787c4ddc32c9f966c2fd4253af80..22a207030247f81fc929edc6d601b744abbda762 100644 (file)
@@ -182,6 +182,9 @@ class CalendarMigrator implements IMigrator, ISizeEstimationMigrator {
                )));
        }
 
+       /**
+        * @throws InvalidCalendarException
+        */
        private function getUniqueCalendarUri(IUser $user, string $initialCalendarUri): string {
                $principalUri = $this->getPrincipalUri($user);
 
@@ -190,7 +193,7 @@ class CalendarMigrator implements IMigrator, ISizeEstimationMigrator {
                        : CalendarMigrator::MIGRATED_URI_PREFIX . $initialCalendarUri;
 
                if ($initialCalendarUri === '') {
-                       throw new CalendarMigratorException('Failed to get unique calendar URI');
+                       throw new InvalidCalendarException();
                }
 
                $existingCalendarUris = array_map(
@@ -457,17 +460,20 @@ class CalendarMigrator implements IMigrator, ISizeEstimationMigrator {
                                        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;