mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-08 01:45:32 +00:00
change(ios/engine): start of cloud -> KMP migration method
This commit is contained in:
parent
28edcdd7f9
commit
047b7a2be7
2 changed files with 31 additions and 0 deletions
|
|
@ -490,4 +490,30 @@ public enum Migrations {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func migrateCloudResourcesToKMPFormat() throws {
|
||||
let cachedKMPsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
|
||||
|
||||
do {
|
||||
let files = try FileManager.default.contentsOfDirectory(atPath: cachedKMPsDirectory.path)
|
||||
let kmpFiles = files.filter { $0.suffix(4) == ".kmp" }
|
||||
|
||||
// Step 1 - analyze all locally-cached KMPs for possible resource sources.
|
||||
let cachedPackages: [KeymanPackage] = kmpFiles.compactMap { file in
|
||||
let filePath = cachedKMPsDirectory.appendingPathComponent(file)
|
||||
do {
|
||||
return try ResourceFileManager.shared.prepareKMPInstall(from: filePath)
|
||||
} catch {
|
||||
log.debug("Error occurred when processing existing packages during cloud -> KMP migration: \(String(describing: error))")
|
||||
return nil as KeymanPackage?
|
||||
}
|
||||
}
|
||||
|
||||
let userDefaults = Storage.active.userDefaults
|
||||
// let userKeyboards = userDefaults.userKeyboards
|
||||
// let userLexicalModels = userDefaults.userLexicalModels
|
||||
} catch {
|
||||
// TODO:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,11 @@ class MigrationTests: XCTestCase {
|
|||
|
||||
// TODO: Actual migration unit testing. So far, this is really more of a
|
||||
// TestUtils.Migrations.applyBundleToFileSystem unit test.
|
||||
do {
|
||||
try Migrations.migrateCloudResourcesToKMPFormat()
|
||||
} catch {
|
||||
// TODO:
|
||||
}
|
||||
}
|
||||
|
||||
func testVersion12ResourceMigration() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue