mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-03 22:27:41 +00:00
fix(ios/engine): fixes older migration breakages
This commit is contained in:
parent
d140a241a6
commit
fb4f02a410
4 changed files with 7 additions and 12 deletions
|
|
@ -259,7 +259,7 @@ extension Storage {
|
|||
// Since we only want to do this installation the first time (rather than constantly force-reinstalling
|
||||
// the resource), we don't want this excluded from backup.
|
||||
try Storage.copy(from: bundle,
|
||||
resourceName: "\(Defaults.keyboard.id)-\(Defaults.keyboard.version).js",
|
||||
resourceName: "\(Defaults.keyboard.id).js",
|
||||
dstDir: defaultKeyboardDir,
|
||||
excludeFromBackup: false)
|
||||
try Storage.copy(from: bundle,
|
||||
|
|
@ -276,25 +276,17 @@ extension Storage {
|
|||
// Since we only want to do this installation the first time (rather than constantly force-reinstalling
|
||||
// the resource), we don't want this excluded from backup.
|
||||
try Storage.copy(from: bundle,
|
||||
resourceName: "\(Defaults.lexicalModel.id)-\(Defaults.lexicalModel.version).model.kmp",
|
||||
resourceName: "\(Defaults.lexicalModel.id).model.kmp",
|
||||
dstDir: defaultLexicalModelDir,
|
||||
excludeFromBackup: false)
|
||||
|
||||
// Perform an auto-install of the lexical model's KMP if not already installed.
|
||||
let lexicalModelURLasZIP = Storage.active.lexicalModelPackageURL(forID: Defaults.lexicalModel.id,
|
||||
asZip: true)
|
||||
let lexicalModelURL = Storage.active.lexicalModelPackageURL(forID: Defaults.lexicalModel.id,
|
||||
asZip: false)
|
||||
|
||||
// Because of how our .zip dependency works, we need to make the .kmp look like a .zip. A simple rename will do.
|
||||
do {
|
||||
try Storage.copy(at: lexicalModelURL, to: lexicalModelURLasZIP, excludeFromBackup: true)
|
||||
let downloader = ResourceDownloadQueue()
|
||||
|
||||
// Hijacking the download queue's KMP installer.
|
||||
// Issue - requests DL confirmation
|
||||
// Issue - in a roundabout way, results in attempted access to Manager.shared during Manager.init, causing crash.
|
||||
_ = downloader.installLexicalModelPackage(downloadedPackageFile: lexicalModelURLasZIP)
|
||||
let package = try ResourceFileManager.shared.prepareKMPInstall(from: lexicalModelURL)
|
||||
try ResourceFileManager.shared.finalizePackageInstall(package, isCustom: false)
|
||||
} catch {
|
||||
log.error("Failed to install the default lexical model from the bundled KMP: \(error)")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ class MigrationTests: XCTestCase {
|
|||
|
||||
func testVersion12AdhocMigration() throws {
|
||||
TestUtils.Migrations.applyBundleToFileSystem(TestUtils.Migrations.adhoc_12)
|
||||
Storage.active.userDefaults.lastEngineVersion = Version.firstTracked
|
||||
Migrations.migrate(storage: Storage.active)
|
||||
|
||||
// The files in the .documents directory should be erased after this method is run.
|
||||
|
|
@ -69,6 +70,7 @@ class MigrationTests: XCTestCase {
|
|||
|
||||
func testVersion10ResourceMigration() {
|
||||
TestUtils.Migrations.applyBundleToFileSystem(TestUtils.Migrations.simple_10)
|
||||
Storage.active.userDefaults.lastEngineVersion = nil
|
||||
Migrations.updateResources(storage: Storage.active)
|
||||
|
||||
let userDefaults = Storage.active.userDefaults
|
||||
|
|
@ -98,6 +100,7 @@ class MigrationTests: XCTestCase {
|
|||
TestUtils.Migrations.applyBundleToFileSystem(TestUtils.Migrations.noDefault_10)
|
||||
Migrations.updateResources(storage: Storage.active)
|
||||
|
||||
Storage.active.userDefaults.lastEngineVersion = nil
|
||||
let userDefaults = Storage.active.userDefaults
|
||||
|
||||
// No new resources should be installed - only what was originally present should be there.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue