[#278] netmap: Migrate from the old storage format
Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
parent
55ffc8f53c
commit
c3b00e0011
1 changed files with 19 additions and 0 deletions
|
@ -94,6 +94,25 @@ func _deploy(data interface{}, isUpdate bool) {
|
|||
|
||||
if isUpdate {
|
||||
common.CheckVersion(args.version)
|
||||
|
||||
count := getSnapshotCount(ctx)
|
||||
prefix := []byte(snapshotKeyPrefix)
|
||||
for i := 0; i < count; i++ {
|
||||
key := append(prefix, byte(i))
|
||||
data := storage.Get(ctx, key)
|
||||
if data != nil {
|
||||
nodes := std.Deserialize(data.([]byte)).([]Node)
|
||||
for i := range nodes {
|
||||
// Old structure contains only the first field,
|
||||
// second is implicitly assumed to be Online.
|
||||
nodes[i] = Node{
|
||||
BLOB: nodes[i].BLOB,
|
||||
State: NodeStateOnline,
|
||||
}
|
||||
}
|
||||
common.SetSerialized(ctx, key, nodes)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue