|
10 | 10 | namespace OCA\UserMigration\Service; |
11 | 11 |
|
12 | 12 | use OC\AppFramework\Bootstrap\Coordinator; |
13 | | -use OC\Cache\CappedMemoryCache; |
14 | 13 | use OCA\UserMigration\BackgroundJob\UserExportJob; |
15 | 14 | use OCA\UserMigration\BackgroundJob\UserImportJob; |
16 | 15 | use OCA\UserMigration\Db\UserExport; |
|
21 | 20 | use OCA\UserMigration\NotExportableException; |
22 | 21 | use OCP\AppFramework\Db\DoesNotExistException; |
23 | 22 | use OCP\BackgroundJob\IJobList; |
| 23 | +use OCP\Cache\CappedMemoryCache; |
24 | 24 | use OCP\Files\File; |
25 | 25 | use OCP\Files\IRootFolder; |
26 | 26 | use OCP\Files\NotFoundException; |
| 27 | +use OCP\IAppConfig; |
27 | 28 | use OCP\IConfig; |
28 | 29 | use OCP\IUser; |
29 | 30 | use OCP\IUserManager; |
|
42 | 43 | class UserMigrationService { |
43 | 44 | use TMigratorBasicVersionHandling; |
44 | 45 |
|
45 | | - protected IRootFolder $root; |
46 | | - |
47 | | - protected IConfig $config; |
48 | | - |
49 | | - protected IUserManager $userManager; |
50 | | - |
51 | | - protected ContainerInterface $container; |
52 | | - |
53 | | - // Allow use of the private Coordinator class here to get and run registered migrators |
54 | | - protected Coordinator $coordinator; |
55 | | - |
56 | | - protected UserExportMapper $exportMapper; |
57 | | - |
58 | | - protected UserImportMapper $importMapper; |
59 | | - |
60 | | - protected IJobList $jobList; |
61 | | - |
62 | 46 | protected CappedMemoryCache $internalCache; |
63 | 47 |
|
64 | 48 | protected const ENTITY_JOB_MAP = [ |
65 | 49 | UserExport::class => UserExportJob::class, |
66 | 50 | UserImport::class => UserImportJob::class, |
67 | 51 | ]; |
68 | 52 |
|
| 53 | + // Allow use of the private Coordinator class here to get and run registered migrators |
69 | 54 | public function __construct( |
70 | | - IRootFolder $rootFolder, |
71 | | - IConfig $config, |
72 | | - IUserManager $userManager, |
73 | | - ContainerInterface $container, |
74 | | - Coordinator $coordinator, |
75 | | - UserExportMapper $exportMapper, |
76 | | - UserImportMapper $importMapper, |
77 | | - IJobList $jobList, |
| 55 | + private IRootFolder $rootFolder, |
| 56 | + private IConfig $config, |
| 57 | + private IUserManager $userManager, |
| 58 | + private ContainerInterface $container, |
| 59 | + private Coordinator $coordinator, |
| 60 | + private UserExportMapper $exportMapper, |
| 61 | + private UserImportMapper $importMapper, |
| 62 | + private IJobList $jobList, |
| 63 | + private IAppConfig $appConfig, |
78 | 64 | ) { |
79 | | - $this->root = $rootFolder; |
80 | | - $this->config = $config; |
81 | | - $this->userManager = $userManager; |
82 | | - $this->container = $container; |
83 | | - $this->coordinator = $coordinator; |
84 | | - $this->exportMapper = $exportMapper; |
85 | | - $this->importMapper = $importMapper; |
86 | | - $this->jobList = $jobList; |
87 | 65 | $this->internalCache = new CappedMemoryCache(); |
88 | 66 |
|
89 | 67 | $this->mandatory = true; |
@@ -132,7 +110,7 @@ public function estimateExportSize(IUser $user, ?array $filteredMigratorList = n |
132 | 110 | */ |
133 | 111 | public function checkExportability(IUser $user, ?array $filteredMigratorList = null): void { |
134 | 112 | try { |
135 | | - $userFolder = $this->root->getUserFolder($user->getUID()); |
| 113 | + $userFolder = $this->rootFolder->getUserFolder($user->getUID()); |
136 | 114 | $freeSpace = ceil($userFolder->getFreeSpace() / 1024); |
137 | 115 | } catch (Throwable $e) { |
138 | 116 | throw new NotExportableException('Error calculating amount of free storage space available'); |
@@ -299,7 +277,7 @@ protected function exportVersions(string $uid, |
299 | 277 |
|
300 | 278 | $versions = array_merge( |
301 | 279 | ['core' => $this->config->getSystemValue('version')], |
302 | | - \OC_App::getAppVersions() |
| 280 | + $this->appConfig->getAppInstalledVersions() |
303 | 281 | ); |
304 | 282 |
|
305 | 283 | try { |
|
0 commit comments