diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-04-28 12:47:04 +0300 |
---|---|---|
committer | Côme Chilliet (Rebase PR Action) <come-nc@users.noreply.github.com> | 2022-05-30 10:36:13 +0300 |
commit | 09917b85838d6cf8f075eadfac65a674be2c4316 (patch) | |
tree | 9bf1a7c7ca34b59ca1f9e7ac6b2f5bdad83be623 /apps/settings | |
parent | f20b7e576484d9d7654763e60707115d93655df9 (diff) |
Implement getExportEstimatedSize in migrators
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/settings')
-rw-r--r-- | apps/settings/lib/UserMigration/AccountMigrator.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/apps/settings/lib/UserMigration/AccountMigrator.php b/apps/settings/lib/UserMigration/AccountMigrator.php index 7b60a101cee..733d4a0b75d 100644 --- a/apps/settings/lib/UserMigration/AccountMigrator.php +++ b/apps/settings/lib/UserMigration/AccountMigrator.php @@ -71,6 +71,27 @@ class AccountMigrator implements IMigrator { /** * {@inheritDoc} */ + public function getExportEstimatedSize(IUser $user): int { + $uid = $user->getUID(); + + $size = 100; // 100KiB for account JSON + + try { + $avatar = $this->avatarManager->getAvatar($user->getUID()); + if ($avatar->isCustomAvatar()) { + $avatarFile = $avatar->getFile(-1); + $size += $avatarFile->getSize() / 1024; + } + } catch (Throwable $e) { + return 0; + } + + return (int)ceil($size); + } + + /** + * {@inheritDoc} + */ public function export(IUser $user, IExportDestination $exportDestination, OutputInterface $output): void { $output->writeln('Exporting account information in ' . AccountMigrator::PATH_ACCOUNT_FILE . '…'); |