-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.php
56 lines (46 loc) · 1.81 KB
/
main.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
require __DIR__ . '/vendor/autoload.php';
use MigrationS3NC\Configuration\NextcloudS3Configuration;
use MigrationS3NC\Constants;
use MigrationS3NC\Environment;
use MigrationS3NC\File\FileNextcloudConfiguration;
use MigrationS3NC\Managers\File\FileLocalStorageManager;
use MigrationS3NC\Managers\File\FileUserManager;
use MigrationS3NC\Managers\S3\S3Manager;
use MigrationS3NC\Managers\Storage\HomeStorageManager;
use MigrationS3NC\Managers\Storage\LocalStorageManager;
use MigrationS3NC\Service\StorageService;
Environment::load();
$fileManager = new FileUserManager();
$filesLocalStorageManager = new FileLocalStorageManager();
$s3Manager = new S3Manager();
$commands = $s3Manager->generatorPubObject(
array_merge(
$fileManager->getAll(),
$filesLocalStorageManager->getAll()
)
);
$pool = $s3Manager->pool($commands);
$promise = $pool->promise();
$promise->wait();
// update the oc_storages table database
$HomeStorageManager = new HomeStorageManager();
foreach ($HomeStorageManager->getAll() as $storage) {
$HomeStorageManager
->updateId(
$storage->getNumericId(),
Constants::ID_USER_OBJECT . $storage->getUid()
);
}
$localStorageManager = new LocalStorageManager();
// We manage a monobucket for the momment...
$idObjectStorage = StorageService::getNewIdLocalStorage();
$localStorage = $localStorageManager->getAll()[0];
$localStorageManager->updateId($storage->getNumericId(), $idObjectStorage);
$data = NextcloudS3Configuration::getS3Configuration();
$file = new FileNextcloudConfiguration("new_config.php");
$file->write($data);
$file->close();
print("\nCongrulation ! The migration is done ! 🎉 🪣\n");
print("You should move the new_config.php file and replace Nextcloud's config.php file with it.\n");
print("Please, check if it's new config is correct !\n\n");