Skip to content

Commit

Permalink
ui: import only file schemes
Browse files Browse the repository at this point in the history
  • Loading branch information
osy committed Aug 12, 2021
1 parent 94a9a01 commit 41e171b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Jitterbug/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ struct ContentView: View {
}.alert(item: $main.alertMessage) { message in
Alert(title: Text(message))
}.onOpenURL { url in
guard url.scheme == "file" else {
return // ignore jitterbug urls
}
main.backgroundTask(message: NSLocalizedString("Importing pairing...", comment: "ContentView")) {
try main.importPairing(url)
Thread.sleep(forTimeInterval: 1)
Expand Down
3 changes: 3 additions & 0 deletions Jitterbug/Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ class Main: NSObject, ObservableObject {

private func importFile(_ file: URL, toDirectory: URL, onComplete: @escaping () -> Void) throws {
let name = file.lastPathComponent
guard name.count > 0 else {
throw NSLocalizedString("Invalid filename.", comment: "Main")
}
let dest = toDirectory.appendingPathComponent(name)
_ = file.startAccessingSecurityScopedResource()
defer {
Expand Down

0 comments on commit 41e171b

Please sign in to comment.