Skip to content
Snippets Groups Projects

Fix purge for wasm-utils localstorage

Merged Jono Wenger requested to merge xx-4687/ekv-js-storage into project/base32768
1 file
+ 4
26
Compare changes
  • Side-by-side
  • Inline
+ 4
26
@@ -16,7 +16,6 @@ import (
"github.com/hack-pad/go-indexeddb/idb"
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/v4/storage/utility"
"gitlab.com/elixxir/wasm-utils/exception"
"gitlab.com/elixxir/wasm-utils/storage"
)
@@ -45,17 +44,14 @@ func DecrementNumClientsRunning() {
// password is required.
//
// Parameters:
// - args[0] - Storage directory path (string). This is the same directory
// path passed into [wasm.NewCmix].
// - args[1] - The user-supplied password (string). This is the same password
// - args[0] - The user-supplied password (string). This is the same password
// passed into [wasm.NewCmix].
//
// Returns:
// - Throws an error if the password is incorrect or if not all cMix
// followers have been stopped.
// - Throws an error if the password is incorrect or if not all cMix followers
// have been stopped.
func Purge(_ js.Value, args []js.Value) any {
storageDirectory := args[0].String()
userPassword := args[1].String()
userPassword := args[0].String()
// Check the password
if !verifyPassword(userPassword) {
@@ -96,23 +92,5 @@ func Purge(_ js.Value, args []js.Value) any {
n := ls.Clear()
jww.DEBUG.Printf("[PURGE] Cleared %d WASM keys in local storage", n)
// Clear all EKV from local storage
keys := ls.LocalStorageUNSAFE().KeysPrefix(storageDirectory)
n = len(keys)
for _, keyName := range keys {
ls.LocalStorageUNSAFE().RemoveItem(keyName)
}
jww.DEBUG.Printf("[PURGE] Cleared %d keys with the prefix %q (for EKV)",
n, storageDirectory)
// Clear all NDFs saved to local storage
keys = ls.LocalStorageUNSAFE().KeysPrefix(utility.NdfStorageKeyNamePrefix)
n = len(keys)
for _, keyName := range keys {
ls.LocalStorageUNSAFE().RemoveItem(keyName)
}
jww.DEBUG.Printf("[PURGE] Cleared %d keys with the prefix %q (for NDF)",
n, utility.NdfStorageKeyNamePrefix)
return nil
}
Loading