File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -58,22 +58,29 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
5858 return false
5959 }
6060
61- documentBrowserViewController. revealDocument ( at: inputURL, importIfNeeded: true ) { ( revealedDocumentURL, error) in
62-
63- guard error == nil else {
64- Crashlytics . crashlytics ( ) . record ( error: error!)
65- fatalError ( " error is not null " )
66-
67- return
68- }
69-
70- guard let url = revealedDocumentURL else {
71- fatalError ( " revealedDocumentURL is null " )
61+ let documentsUrl = FileManager . default. urls ( for: . documentDirectory, in: . userDomainMask) . first!
62+ let inboxUrl = documentsUrl. appendingPathComponent ( " Inbox " )
63+
64+ let destinationUrl : URL
65+ if ( inputURL. absoluteString. contains ( inboxUrl. absoluteString) ) {
66+ do {
67+ destinationUrl = documentsUrl. appendingPathComponent ( inputURL. lastPathComponent)
68+
69+ try FileManager . default. moveItem ( at: inputURL, to: destinationUrl)
70+ } catch {
71+ print ( error)
72+ fatalError ( " copying from Inbox failed " )
7273
73- return
74+ return false
7475 }
76+ } else {
77+ destinationUrl = inputURL
78+ }
79+
80+ documentBrowserViewController. revealDocument ( at: destinationUrl, importIfNeeded: true ) { ( revealedDocumentURL, error) in
81+ // ignoring errors because they should pop up in failedToImportDocumentAt too
7582
76- documentBrowserViewController. presentDocument ( at: url )
83+ documentBrowserViewController. presentDocument ( at: revealedDocumentURL! )
7784 }
7885
7986 return true
You can’t perform that action at this time.
0 commit comments