Skip to content

Commit

Permalink
fix: remove deleteOnFinish and added documentation (#1418)
Browse files Browse the repository at this point in the history
Signed-off-by: blu3beri <[email protected]>
  • Loading branch information
berendsliedrecht authored Apr 4, 2023
1 parent c888736 commit c8b16a6
Showing 1 changed file with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,22 @@ export class IndySdkToAskarMigrationUpdater {
private agent: Agent
private dbPath: string
private fs: FileSystem
private deleteOnFinish: boolean

private constructor(
walletConfig: WalletConfig,
agent: Agent,
dbPath: string,
deleteOnFinish = false,
defaultLinkSecretId?: string
) {
private constructor(walletConfig: WalletConfig, agent: Agent, dbPath: string, defaultLinkSecretId?: string) {
this.walletConfig = walletConfig
this.dbPath = dbPath
this.agent = agent
this.fs = this.agent.dependencyManager.resolve<FileSystem>(InjectionSymbols.FileSystem)
this.defaultLinkSecretId = defaultLinkSecretId ?? walletConfig.id
this.deleteOnFinish = deleteOnFinish
}

public static async initialize({
dbPath,
agent,
deleteOnFinish,
defaultLinkSecretId,
}: {
dbPath: string
agent: Agent
deleteOnFinish?: boolean
defaultLinkSecretId?: string
}) {
const {
Expand Down Expand Up @@ -83,7 +73,7 @@ export class IndySdkToAskarMigrationUpdater {
throw new IndySdkToAskarMigrationError("Wallet on the agent must be of instance 'AskarWallet'")
}

return new IndySdkToAskarMigrationUpdater(walletConfig, agent, dbPath, deleteOnFinish, defaultLinkSecretId)
return new IndySdkToAskarMigrationUpdater(walletConfig, agent, dbPath, defaultLinkSecretId)
}

/**
Expand Down Expand Up @@ -186,14 +176,16 @@ export class IndySdkToAskarMigrationUpdater {

// Copy the file from the database path to the new location
await this.fs.copyFile(src, dest)

// Delete the original, only if specified by the user
if (this.deleteOnFinish) await this.fs.delete(this.dbPath)
}

/**
* Function that updates the values from an indy-sdk structure to the new askar structure.
*
* > NOTE: It is very important that this script is ran before the 0.3.x to
* 0.4.x migration script. This can easily be done by calling this when you
* upgrade, before you initialize the agent with `autoUpdateStorageOnStartup:
* true`.
*
* - Assert that the paths that will be used are free
* - Create a backup of the database
* - Migrate the database to askar structure
Expand Down

0 comments on commit c8b16a6

Please sign in to comment.