|
@@ -395,14 +395,21 @@ extension KMHomeViewController {
|
|
|
selectDocument?.browser.window.orderFront(nil)
|
|
|
}
|
|
|
} else {
|
|
|
- NSDocumentController.shared.openDocument(withContentsOf: url, display: true) { document, documentWasAlreadyOpen, error in
|
|
|
- if error != nil {
|
|
|
- NSApp.presentError(error!)
|
|
|
- return
|
|
|
- }
|
|
|
+ if !url.path.isPDFValid() {
|
|
|
+ let alert = NSAlert()
|
|
|
+ alert.alertStyle = .critical
|
|
|
+ alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
|
|
|
+ alert.runModal()
|
|
|
+ } else {
|
|
|
+ NSDocumentController.shared.openDocument(withContentsOf: url, display: true) { document, documentWasAlreadyOpen, error in
|
|
|
+ if error != nil {
|
|
|
+ NSApp.presentError(error!)
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
-// (document as! KMMainDocument).mainViewController.listView.document.unlock(withPassword: password)
|
|
|
- (document as! KMMainDocument).mainViewController?.password = password
|
|
|
+ // (document as! KMMainDocument).mainViewController.listView.document.unlock(withPassword: password)
|
|
|
+ (document as! KMMainDocument).mainViewController?.password = password
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -422,10 +429,17 @@ extension KMHomeViewController {
|
|
|
selectDocument?.browser.window.orderFront(nil)
|
|
|
}
|
|
|
} else {
|
|
|
- NSDocumentController.shared.openDocument(withContentsOf: url, display: true) { document, documentWasAlreadyOpen, error in
|
|
|
- if error != nil {
|
|
|
- NSApp.presentError(error!)
|
|
|
- return
|
|
|
+ if !url.path.isPDFValid() {
|
|
|
+ let alert = NSAlert()
|
|
|
+ alert.alertStyle = .critical
|
|
|
+ alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
|
|
|
+ alert.runModal()
|
|
|
+ } else {
|
|
|
+ NSDocumentController.shared.openDocument(withContentsOf: url, display: true) { document, documentWasAlreadyOpen, error in
|
|
|
+ if error != nil {
|
|
|
+ NSApp.presentError(error!)
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -446,10 +460,17 @@ extension KMHomeViewController {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- NSDocumentController.shared.openDocument(withContentsOf: url, display: true) { document, documentWasAlreadyOpen, error in
|
|
|
- if error != nil {
|
|
|
- NSApp.presentError(error!)
|
|
|
- return
|
|
|
+ if !url.path.isPDFValid() {
|
|
|
+ let alert = NSAlert()
|
|
|
+ alert.alertStyle = .critical
|
|
|
+ alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
|
|
|
+ alert.runModal()
|
|
|
+ } else {
|
|
|
+ NSDocumentController.shared.openDocument(withContentsOf: url, display: true) { document, documentWasAlreadyOpen, error in
|
|
|
+ if error != nil {
|
|
|
+ NSApp.presentError(error!)
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|