Skip to content
This repository was archived by the owner on Mar 4, 2023. It is now read-only.

Commit 903bbd5

Browse files
committed
added migrationhelper doc
1 parent a2befbe commit 903bbd5

File tree

3 files changed

+65
-11
lines changed

3 files changed

+65
-11
lines changed

doc/migrationhelper.dox

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*!
2+
@class QtDataSync::MigrationHelper
3+
4+
If you used QtDataSync below version 4 before, you will have to use this class to migrate the data
5+
from that old datasync to the current new one, as they are not compatible. This is what this class
6+
is used for.
7+
8+
The migration is performed asynchronously once started and cannot be stopped. To start a
9+
migration, use startMigration().
10+
11+
@sa MigrationHelper::startMigration, MigrationHelper::migrationDone
12+
*/
13+
14+
/*!
15+
@fn QtDataSync::MigrationHelper::MigrationHelper(QObject *)
16+
17+
@param parent The parent object
18+
@throws SetupDoesNotExistException Thrown if the default setup was not created yet
19+
*/
20+
21+
/*!
22+
@fn QtDataSync::MigrationHelper::MigrationHelper(const QString &, QObject *)
23+
24+
@param setupName The name of the setup to connect to
25+
@param parent The parent object
26+
@throws SetupDoesNotExistException Thrown if the given setup was not created yet
27+
*/
28+
29+
/*!
30+
@fn QtDataSync::MigrationHelper::startMigration
31+
32+
@param storageDir The old datasync directory to import the data from
33+
@param flags Flags to configure what and how to migrate the data
34+
35+
The `storageDir` must be the directory that the old datasync used as storage directory. If you
36+
did not change it, the DefaultOldStorageDir constant can be used, as it points to the previous
37+
default datasync storage dir.
38+
39+
Migration is performed asynchronously with the status beeing reported via the signals. Errors,
40+
warnings and other stuff is logged as usual. Use the `qtdatasync.<setupName>.migration` logging
41+
category to filter for it.
42+
43+
@sa MigrationHelper::MigrationFlag, MigrationHelper::DefaultOldStorageDir,
44+
MigrationHelper::migrationDone, MigrationHelper::migrationPrepared,
45+
MigrationHelper::migrationProgress,
46+
*/

src/datasync/migrationhelper.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,6 @@ void MigrationRunnable::run()
169169
currentSettings, QStringLiteral("connector/") + RemoteConnector::keyRemoteEnabled);
170170
copyConf(oldSettings, QStringLiteral("RemoteConnector/remoteUrl"),
171171
currentSettings, QStringLiteral("connector/") + RemoteConnector::keyRemoteUrl);
172-
// copyConf(oldSettings, QStringLiteral("RemoteConnector/verifyPeer"),
173-
// currentSettings, QStringLiteral("connector/remote/verifyPeer")); //TODO add?
174172
copyConf(oldSettings, QStringLiteral("RemoteConnector/sharedSecret"),
175173
currentSettings, QStringLiteral("connector/") + RemoteConnector::keyRemoteAccessKey);
176174

src/datasync/migrationhelper.h

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,46 @@
99
namespace QtDataSync {
1010

1111
class MigrationHelperPrivate;
12+
//! A helper class to migrate data from DataSync 3.0 to this version
1213
class Q_DATASYNC_EXPORT MigrationHelper : public QObject
1314
{
1415
Q_OBJECT
1516

1617
public:
18+
//! Flags to configure what and how should be migrated
1719
enum MigrationFlag {
18-
MigrateData = 0x01,
19-
MigrateChanged = (0x02 | MigrateData),
20-
MigrateRemoteConfig = 0x04,
21-
MigrateAll = (MigrateData | MigrateChanged | MigrateRemoteConfig),
22-
23-
MigrateWithCleanup = 0x08,
24-
MigrateOverwriteConfig = 0x10,
25-
MigrateOverwriteData = 0x20
20+
MigrateData = 0x01, //!< Migrate actual stored data
21+
MigrateChanged = (0x02 | MigrateData), //!< Migrate the changed state of that data
22+
MigrateRemoteConfig = 0x04, //!< Migrate the connection configuration
23+
24+
MigrateWithCleanup = 0x08, //!< Remove all old data after a successful migration
25+
MigrateOverwriteConfig = 0x10, //!< Overwrite existing configurations with the migrated remote config
26+
MigrateOverwriteData = 0x20, //!< Overwrite existing data with the migrated data
27+
28+
MigrateDefault = (MigrateData | MigrateRemoteConfig | MigrateWithCleanup) //!< The default flags when leaving out the parameter
2629
};
2730
Q_DECLARE_FLAGS(MigrationFlags, MigrationFlag)
2831
Q_FLAG(MigrationFlags)
2932

33+
//! The previous default path where data was stored
3034
static const QString DefaultOldStorageDir;
3135

36+
//! Default constructor, uses the default setup
3237
explicit MigrationHelper(QObject *parent = nullptr);
38+
//! Constructor with an explicit setup
3339
explicit MigrationHelper(const QString &setupName, QObject *parent = nullptr);
3440
~MigrationHelper();
3541

3642
public Q_SLOTS:
37-
void startMigration(const QString &storageDir = DefaultOldStorageDir, MigrationFlags flags = MigrationFlags(MigrateAll) | MigrateWithCleanup);
43+
//! Start the migration process from the given directory with flags
44+
void startMigration(const QString &storageDir = DefaultOldStorageDir, MigrationFlags flags = MigrateDefault);
3845

3946
Q_SIGNALS:
47+
//! Is emitted when the number of migrate operations has been determined
4048
void migrationPrepared(int operations);
49+
//! Is emitted for every successful migration step done to give a progress
4150
void migrationProgress(int current);
51+
//! Is emitted when the migration has been finished
4252
void migrationDone(bool ok);
4353

4454
private:

0 commit comments

Comments
 (0)