Merge pull request #2461 from keymanapp/cherry/ios/2455/adhoc-file-overwrite

cherry(ios): Adhoc resource overwrite/file-replacement
This commit is contained in:
Joshua Horton 2019-12-19 07:21:59 +07:00 • committed by GitHub
commit 3cea9b6861
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View file

@ -3,6 +3,9 @@
## 13.0 alpha
* Start version 13.0
## 2019-12-19 12.0.63 stable
* Fixed issue with reinstalling or updating previously installed language resources from local files (#2461)
## 2019-12-05 12.0.62 stable
* Fix situation where lexical models would not install (#2420)

View file

@ -26,11 +26,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var destinationUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
destinationUrl.appendPathComponent("\(url.lastPathComponent).zip")
do {
try FileManager.default.copyItem(at: url, to: destinationUrl)
let fileManager = FileManager.default
// For now, we'll always allow overwriting.
if fileManager.fileExists(atPath: destinationUrl.path) {
try fileManager.removeItem(at: destinationUrl)
}
// Throws an error if the destination file already exists, and there's no
// built-in override parameter. Hence, the previous if-block.
try fileManager.copyItem(at: url, to: destinationUrl)
installAdhocKeyboard(url: destinationUrl)
return true
} catch {
showKMPError(KMPError.copyFiles)
log.error(error)
return false
}
}