Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xxdk-wasm
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
xxdk-wasm
Commits
e0c3f9c5
Commit
e0c3f9c5
authored
2 years ago
by
Jake Taylor
Browse files
Options
Downloads
Patches
Plain Diff
fix indexedDb migration code
parent
f9091a63
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!60
Revert "Fail a test to be sure it works"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
indexedDb/init.go
+13
-9
13 additions, 9 deletions
indexedDb/init.go
with
13 additions
and
9 deletions
indexedDb/init.go
+
13
−
9
View file @
e0c3f9c5
...
@@ -13,7 +13,6 @@ import (
...
@@ -13,7 +13,6 @@ import (
"syscall/js"
"syscall/js"
"github.com/hack-pad/go-indexeddb/idb"
"github.com/hack-pad/go-indexeddb/idb"
"github.com/pkg/errors"
jww
"github.com/spf13/jwalterweatherman"
jww
"github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/channels"
"gitlab.com/elixxir/client/channels"
...
@@ -27,7 +26,7 @@ const (
...
@@ -27,7 +26,7 @@ const (
// currentVersion is the current version of the IndexDb
// currentVersion is the current version of the IndexDb
// runtime. Used for migration purposes.
// runtime. Used for migration purposes.
currentVersion
uint
=
1
currentVersion
uint
=
2
)
)
// MessageReceivedCallback is called any time a message is received or updated
// MessageReceivedCallback is called any time a message is received or updated
...
@@ -62,19 +61,24 @@ func newWASMModel(databaseName string, cb MessageReceivedCallback) (
...
@@ -62,19 +61,24 @@ func newWASMModel(databaseName string, cb MessageReceivedCallback) (
openRequest
,
_
:=
idb
.
Global
()
.
Open
(
ctx
,
databaseName
,
currentVersion
,
openRequest
,
_
:=
idb
.
Global
()
.
Open
(
ctx
,
databaseName
,
currentVersion
,
func
(
db
*
idb
.
Database
,
oldVersion
,
newVersion
uint
)
error
{
func
(
db
*
idb
.
Database
,
oldVersion
,
newVersion
uint
)
error
{
if
oldVersion
==
newVersion
{
if
oldVersion
==
newVersion
{
jww
.
INFO
.
Printf
(
"IndexDb version is current: v%d"
,
newVersion
)
jww
.
INFO
.
Printf
(
"IndexDb version is current: v%d"
,
newVersion
)
return
nil
return
nil
}
}
jww
.
INFO
.
Printf
(
jww
.
INFO
.
Printf
(
"IndexDb upgrade required: v%d -> v%d"
,
"IndexDb upgrade required: v%d -> v%d"
,
oldVersion
,
newVersion
)
oldVersion
,
newVersion
)
if
oldVersion
==
0
&&
newVersion
==
1
{
if
oldVersion
==
0
&&
newVersion
>=
1
{
return
v1Upgrade
(
db
)
err
:=
v1Upgrade
(
db
)
if
err
!=
nil
{
return
err
}
oldVersion
=
1
}
}
return
errors
.
Errorf
(
"Invalid version upgrade path: v%d -> v%d"
,
// if oldVersion == 1 && newVersion >= 2 { v2Upgrade(), oldVersion = 2 }
oldVersion
,
newVersion
)
return
nil
})
})
// Wait for database open to finish
// Wait for database open to finish
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment