mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-07 17:36:00 +00:00
fix(ios): better handling of scoped vs non-scoped package URLs
This commit is contained in:
parent
3cd23a5740
commit
54f3bd17ef
1 changed files with 8 additions and 7 deletions
|
|
@ -92,15 +92,16 @@ public class ResourceFileManager {
|
|||
try fileManager.removeItem(at: destination)
|
||||
}
|
||||
|
||||
// Throws an error if the destination file already exists, and there's no
|
||||
// built-in override parameter. Hence, the previous if-block.
|
||||
if source.startAccessingSecurityScopedResource() {
|
||||
defer { source.stopAccessingSecurityScopedResource() } // The Swift version of 'finally'.
|
||||
// If we've been provided a security-scoped resource URL,
|
||||
// it needs special handling. This function needs to accept
|
||||
// both scoped & non-scoped URLs.
|
||||
if source.startAccessingSecurityScopedResource() { // only succeeds if scoped
|
||||
// The Swift version of 'finally'.
|
||||
defer { source.stopAccessingSecurityScopedResource() }
|
||||
try fileManager.copyItem(at: source, to: destination)
|
||||
} else {
|
||||
// We _could_ get more specific, as it's due to issues with security-scoped resources...
|
||||
// but this ought be fine for now.
|
||||
throw KMPError.copyFiles
|
||||
// Not scoped? No problem!
|
||||
try fileManager.copyItem(at: source, to: destination)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue