|
42 | 42 | namespace {
|
43 | 43 | constexpr auto settingsAccountsC = "Accounts";
|
44 | 44 | constexpr auto settingsFoldersC = "Folders";
|
| 45 | +constexpr auto settingsFoldersWithPlaceholdersC = "FoldersWithPlaceholders"; |
45 | 46 | constexpr auto settingsVersionC = "version";
|
46 | 47 | constexpr auto maxFoldersVersion = 1;
|
47 | 48 |
|
@@ -388,16 +389,19 @@ void FolderMan::backwardMigrationSettingsKeys(QStringList *deleteKeys, QStringLi
|
388 | 389 | auto processSubgroup = [&](const QString &name) {
|
389 | 390 | settings->beginGroup(name);
|
390 | 391 | const auto foldersVersion = settings->value(QLatin1String(settingsVersionC), 1).toInt();
|
| 392 | + qCInfo(lcFolderMan) << "FolderDefinition::maxSettingsVersion:" << FolderDefinition::maxSettingsVersion(); |
391 | 393 | if (foldersVersion <= maxFoldersVersion) {
|
392 | 394 | for (const auto &folderAlias : settings->childGroups()) {
|
393 | 395 | settings->beginGroup(folderAlias);
|
394 | 396 | const auto folderVersion = settings->value(QLatin1String(settingsVersionC), 1).toInt();
|
395 | 397 | if (folderVersion > FolderDefinition::maxSettingsVersion()) {
|
| 398 | + qCInfo(lcFolderMan) << "Ignoring folder:" << folderAlias << "version:" << folderVersion; |
396 | 399 | ignoreKeys->append(settings->group());
|
397 | 400 | }
|
398 | 401 | settings->endGroup();
|
399 | 402 | }
|
400 | 403 | } else {
|
| 404 | + qCInfo(lcFolderMan) << "Ignoring group:" << name << "version:" << foldersVersion; |
401 | 405 | deleteKeys->append(settings->group());
|
402 | 406 | }
|
403 | 407 | settings->endGroup();
|
@@ -523,89 +527,97 @@ void FolderMan::setupLegacyFolder(const QString &fileNamePath, AccountState *acc
|
523 | 527 | return;
|
524 | 528 | }
|
525 | 529 |
|
526 |
| - settings.beginGroup(settingsAccountsC); |
527 |
| - qCDebug(lcFolderMan) << "try to migrate accountId:" << accountState->account()->id(); |
528 |
| - settings.beginGroup(accountState->account()->id()); |
529 |
| - settings.beginGroup(settingsFoldersC); |
530 |
| - |
531 |
| - if (settings.childGroups().isEmpty()) { |
532 |
| - qCDebug(lcFolderMan) << "there are no legacy folders for accountId:" << accountState->account()->id(); |
533 |
| - return; |
534 |
| - } |
535 |
| - |
536 |
| - const auto childGroups = settings.childGroups(); |
537 |
| - for (const auto &alias : childGroups) { |
538 |
| - settings.beginGroup(alias); |
539 |
| - qCDebug(lcFolderMan) << "try to migrate folder alias:" << alias; |
540 |
| - |
541 |
| - const auto path = settings.value(QLatin1String("localPath")).toString(); |
542 |
| - const auto targetPath = settings.value(QLatin1String("targetPath")).toString(); |
543 |
| - const auto journalPath = settings.value(QLatin1String("journalPath")).toString(); |
544 |
| - const auto paused = settings.value(QLatin1String("paused"), false).toBool(); |
545 |
| - const auto ignoreHiddenFiles = settings.value(QLatin1String("ignoreHiddenFiles"), false).toBool(); |
546 |
| - |
547 |
| - if (path.isEmpty()) { |
548 |
| - qCDebug(lcFolderMan) << "localPath is empty"; |
549 |
| - settings.endGroup(); |
550 |
| - continue; |
551 |
| - } |
552 |
| - |
553 |
| - if (targetPath.isEmpty()) { |
554 |
| - qCDebug(lcFolderMan) << "targetPath is empty"; |
555 |
| - settings.endGroup(); |
556 |
| - continue; |
| 530 | + auto migrateFoldersGroup = [&](const QString &folderGroupName) { |
| 531 | + const auto childGroups = settings.childGroups(); |
| 532 | + if (childGroups.isEmpty()) { |
| 533 | + qCDebug(lcFolderMan) << "There are no" << folderGroupName << "to migrate from account" << accountState->account()->id(); |
| 534 | + return; |
557 | 535 | }
|
| 536 | + for (const auto &alias : childGroups) { |
| 537 | + settings.beginGroup(alias); |
| 538 | + qCDebug(lcFolderMan) << "try to migrate" << folderGroupName << "alias:" << alias; |
| 539 | + |
| 540 | + const auto path = settings.value(QLatin1String("localPath")).toString(); |
| 541 | + const auto targetPath = settings.value(QLatin1String("targetPath")).toString(); |
| 542 | + const auto journalPath = settings.value(QLatin1String("journalPath")).toString(); |
| 543 | + const auto paused = settings.value(QLatin1String("paused"), false).toBool(); |
| 544 | + const auto ignoreHiddenFiles = settings.value(QLatin1String("ignoreHiddenFiles"), false).toBool(); |
| 545 | + |
| 546 | + if (path.isEmpty()) { |
| 547 | + qCDebug(lcFolderMan) << "localPath is empty"; |
| 548 | + settings.endGroup(); |
| 549 | + continue; |
| 550 | + } |
558 | 551 |
|
559 |
| - if (journalPath.isEmpty()) { |
560 |
| - qCDebug(lcFolderMan) << "journalPath is empty"; |
561 |
| - settings.endGroup(); |
562 |
| - continue; |
563 |
| - } |
| 552 | + if (targetPath.isEmpty()) { |
| 553 | + qCDebug(lcFolderMan) << "targetPath is empty"; |
| 554 | + settings.endGroup(); |
| 555 | + continue; |
| 556 | + } |
564 | 557 |
|
565 |
| - FolderDefinition folderDefinition; |
566 |
| - folderDefinition.alias = alias; |
567 |
| - folderDefinition.localPath = path; |
568 |
| - folderDefinition.targetPath = targetPath; |
569 |
| - folderDefinition.journalPath = journalPath; |
570 |
| - folderDefinition.paused = paused; |
571 |
| - folderDefinition.ignoreHiddenFiles = ignoreHiddenFiles; |
572 |
| - |
573 |
| - if (const auto folder = addFolderInternal(folderDefinition, accountState, std::make_unique<VfsOff>())) { |
574 |
| - auto ok = true; |
575 |
| - auto legacyBlacklist = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, |
576 |
| - &ok); |
577 |
| - if (!ok) { |
578 |
| - qCInfo(lcFolderMan) << "There was a problem retrieving the database selective sync for " << folder; |
| 558 | + if (journalPath.isEmpty()) { |
| 559 | + qCDebug(lcFolderMan) << "journalPath is empty"; |
| 560 | + settings.endGroup(); |
| 561 | + continue; |
579 | 562 | }
|
580 | 563 |
|
581 |
| - legacyBlacklist << settings.value(QLatin1String("blackList")).toStringList(); |
582 |
| - if (!legacyBlacklist.isEmpty()) { |
583 |
| - qCInfo(lcFolderMan) << "Legacy selective sync list found:" << legacyBlacklist; |
584 |
| - for (const auto &legacyFolder : legacyBlacklist) { |
585 |
| - folder->migrateBlackListPath(legacyFolder); |
| 564 | + qCDebug(lcFolderMan) << folderGroupName << "located at" << path; |
| 565 | + |
| 566 | + FolderDefinition folderDefinition; |
| 567 | + folderDefinition.alias = alias; |
| 568 | + folderDefinition.localPath = path; |
| 569 | + folderDefinition.targetPath = targetPath; |
| 570 | + folderDefinition.journalPath = journalPath; |
| 571 | + folderDefinition.paused = paused; |
| 572 | + folderDefinition.ignoreHiddenFiles = ignoreHiddenFiles; |
| 573 | + |
| 574 | + if (const auto folder = addFolderInternal(folderDefinition, accountState, std::make_unique<VfsOff>())) { |
| 575 | + auto ok = true; |
| 576 | + auto legacyBlacklist = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, |
| 577 | + &ok); |
| 578 | + if (!ok) { |
| 579 | + qCInfo(lcFolderMan) << "There was a problem retrieving the database selective sync for " << folder; |
| 580 | + } |
| 581 | + |
| 582 | + legacyBlacklist << settings.value(QLatin1String("blackList")).toStringList(); |
| 583 | + if (!legacyBlacklist.isEmpty()) { |
| 584 | + qCInfo(lcFolderMan) << "Legacy selective sync list found:" << legacyBlacklist; |
| 585 | + for (const auto &legacyFolder : legacyBlacklist) { |
| 586 | + folder->migrateBlackListPath(legacyFolder); |
| 587 | + } |
| 588 | + settings.remove(QLatin1String("blackList")); |
586 | 589 | }
|
587 |
| - settings.remove(QLatin1String("blackList")); |
588 |
| - } |
589 | 590 |
|
590 |
| - folder->saveToSettings(); |
| 591 | + folder->saveToSettings(); |
591 | 592 |
|
592 |
| - qCInfo(lcFolderMan) << "Migrated!" << folder->path(); |
593 |
| - settings.sync(); |
| 593 | + qCInfo(lcFolderMan) << "Migrated!" << folder->path(); |
| 594 | + settings.sync(); |
594 | 595 |
|
595 |
| - if (!folder) { |
596 |
| - continue; |
597 |
| - } |
| 596 | + if (!folder) { |
| 597 | + continue; |
| 598 | + } |
598 | 599 |
|
599 |
| - scheduleFolder(folder); |
600 |
| - emit folderSyncStateChange(folder); |
| 600 | + scheduleFolder(folder); |
| 601 | + emit folderSyncStateChange(folder); |
| 602 | + } |
| 603 | + settings.endGroup(); // folder alias |
601 | 604 | }
|
| 605 | + }; |
602 | 606 |
|
603 |
| - settings.endGroup(); |
604 |
| - } |
| 607 | + settings.beginGroup(settingsAccountsC); |
| 608 | + qCDebug(lcFolderMan) << "try to migrate accountId:" << accountState->account()->id(); |
| 609 | + settings.beginGroup(accountState->account()->id()); |
605 | 610 |
|
| 611 | + settings.beginGroup(settingsFoldersWithPlaceholdersC); |
| 612 | + migrateFoldersGroup(settingsFoldersWithPlaceholdersC); |
606 | 613 | settings.endGroup();
|
| 614 | + |
| 615 | + settings.beginGroup(settingsFoldersC); |
| 616 | + migrateFoldersGroup(settingsFoldersC); |
607 | 617 | settings.endGroup();
|
608 | 618 |
|
| 619 | + settings.endGroup(); |
| 620 | + settings.endGroup(); |
609 | 621 | return;
|
610 | 622 | }
|
611 | 623 |
|
|
0 commit comments