Migrate from nokey on ios to re-keyed (#1345)

This commit is contained in:
Andrea Maria Piana 2019-01-11 11:55:18 +01:00 committed by GitHub
parent d6216f1aa4
commit 59426d628c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -130,6 +130,7 @@ func (s *Service) InitProtocol(address string, password string) error {
v1Path := filepath.Join(s.dataDir, fmt.Sprintf("%s.db", s.installationID)) v1Path := filepath.Join(s.dataDir, fmt.Sprintf("%s.db", s.installationID))
v2Path := filepath.Join(s.dataDir, fmt.Sprintf("%s.v2.db", s.installationID)) v2Path := filepath.Join(s.dataDir, fmt.Sprintf("%s.v2.db", s.installationID))
v3Path := filepath.Join(s.dataDir, fmt.Sprintf("%s.v3.db", s.installationID)) v3Path := filepath.Join(s.dataDir, fmt.Sprintf("%s.v3.db", s.installationID))
v4Path := filepath.Join(s.dataDir, fmt.Sprintf("%s.v4.db", s.installationID))
if err := chat.MigrateDBFile(v0Path, v1Path, "ON", password); err != nil { if err := chat.MigrateDBFile(v0Path, v1Path, "ON", password); err != nil {
return err return err
@ -147,7 +148,13 @@ func (s *Service) InitProtocol(address string, password string) error {
os.Remove(v3Path) os.Remove(v3Path)
} }
persistence, err := chat.NewSQLLitePersistence(v3Path, hashedPassword) // Fix IOS not encrypting database
if err := chat.MigrateDBFile(v3Path, v4Path, "", hashedPassword); err != nil {
os.Remove(v3Path)
os.Remove(v4Path)
}
persistence, err := chat.NewSQLLitePersistence(v4Path, hashedPassword)
if err != nil { if err != nil {
return err return err
} }