aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-embedded
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-02-23 15:18:30 +0100
committerFlorian Dold <florian@dold.me>2023-02-23 15:18:30 +0100
commit339080e014e2a94cf93bb8ef8d5fbe6793ee4c48 (patch)
tree3fa1ed2c3c271fa6c13f191c14a2b6f478ae4f15 /packages/taler-wallet-embedded
parent7985b0a33ffc3e258da5d73f4056384c38e626fe (diff)
embedded: add missing DB remove call in reset
Diffstat (limited to 'packages/taler-wallet-embedded')
-rw-r--r--packages/taler-wallet-embedded/src/wallet-qjs.ts26
1 files changed, 18 insertions, 8 deletions
diff --git a/packages/taler-wallet-embedded/src/wallet-qjs.ts b/packages/taler-wallet-embedded/src/wallet-qjs.ts
index 9cf735b12..9d6a6c097 100644
--- a/packages/taler-wallet-embedded/src/wallet-qjs.ts
+++ b/packages/taler-wallet-embedded/src/wallet-qjs.ts
@@ -30,6 +30,7 @@ import {
Logger,
setGlobalLogLevelFromString,
setPRNG,
+ TalerErrorCode,
WalletNotification,
} from "@gnu-taler/taler-util";
import { createPlatformHttpLib } from "@gnu-taler/taler-util/http";
@@ -74,7 +75,7 @@ class NativeWalletMessageHandler {
id: string,
args: any,
): Promise<CoreApiResponse> {
- const wrapResponse = (result: unknown): CoreApiResponseSuccess => {
+ const wrapSuccessResponse = (result: unknown): CoreApiResponseSuccess => {
return {
type: "response",
id,
@@ -120,7 +121,7 @@ class NativeWalletMessageHandler {
setGlobalLogLevelFromString(logLevel);
}
await reinit();
- return wrapResponse({
+ return wrapSuccessResponse({
...initResponse,
});
}
@@ -137,14 +138,22 @@ class NativeWalletMessageHandler {
throw Error("not implemented");
}
case "reset": {
+ logger.info("resetting wallet");
const oldArgs = this.walletArgs;
this.walletArgs = { ...oldArgs };
if (oldArgs && oldArgs.persistentStoragePath) {
- try {
- logger.error("FIXME: reset not implemented");
- // fs.unlinkSync(oldArgs.persistentStoragePath);
- } catch (e) {
- logger.error("Error while deleting the wallet db:", e);
+ const ret = qjsOs.remove(oldArgs.persistentStoragePath);
+ if (ret != null) {
+ return {
+ type: "error",
+ id,
+ operation,
+ error: {
+ code: TalerErrorCode.GENERIC_UNEXPECTED_REQUEST_ERROR,
+ hint: `path ${oldArgs.persistentStoragePath}`,
+ message: "removing DB file failed",
+ },
+ };
}
// Prevent further storage!
this.walletArgs.persistentStoragePath = undefined;
@@ -154,7 +163,8 @@ class NativeWalletMessageHandler {
this.wp = openPromise<Wallet>();
this.maybeWallet = undefined;
await reinit();
- return wrapResponse({});
+ logger.info("wallet re-initialized after reset");
+ return wrapSuccessResponse({});
}
default: {
const wallet = await this.wp.promise;