Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2022-04-29 06:03:01 +0300
committerChristopher Ng <chrng8@gmail.com>2022-05-31 01:48:15 +0300
commitaaedc95e817c55576ed7413bc2220800bb66ef85 (patch)
tree345c20934ecd5ae928bc5926df7d5fc32a7fce87 /apps
parent9fbbbc7ca6767ac401d94ee035dd57ae070aae24 (diff)
Update calendar estimation
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/UserMigration/CalendarMigrator.php23
1 files changed, 17 insertions, 6 deletions
diff --git a/apps/dav/lib/UserMigration/CalendarMigrator.php b/apps/dav/lib/UserMigration/CalendarMigrator.php
index 5a296a2b527..057f7dce77d 100644
--- a/apps/dav/lib/UserMigration/CalendarMigrator.php
+++ b/apps/dav/lib/UserMigration/CalendarMigrator.php
@@ -51,6 +51,7 @@ 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;
@@ -211,15 +212,25 @@ class CalendarMigrator implements IMigrator, ISizeEstimationMigrator {
* {@inheritDoc}
*/
public function getEstimatedExportSize(IUser $user): int {
- $principalUri = $this->getPrincipalUri($user);
+ $calendarExports = $this->getCalendarExports($user, new NullOutput());
+ $calendarCount = count($calendarExports);
+
+ // 150B for top-level properties
+ $size = ($calendarCount * 150) / 1024;
- return array_sum(array_map(
- function (ICalendar $calendar) use ($user): int {
- // FIXME 1MiB by calendar, no idea if this is accurate and if we should go into more details
- return 1000;
+ $componentCount = array_sum(array_map(
+ function (array $data): int {
+ /** @var VCalendar $vCalendar */
+ $vCalendar = $data['vCalendar'];
+ return count($vCalendar->getComponents());
},
- $this->calendarManager->getCalendarsForPrincipal($principalUri),
+ $calendarExports,
));
+
+ // 450B for each component (events, todos, alarms, etc.)
+ $size += ($componentCount * 450) / 1024;
+
+ return (int)ceil($size);
}
/**