Fix thumbnail provider
This commit is contained in:
parent
7f95910528
commit
1c52fc0e8e
2 changed files with 52 additions and 60 deletions
|
@ -4,12 +4,8 @@ import Cocoa
|
||||||
|
|
||||||
class ThumbnailProvider: QLThumbnailProvider {
|
class ThumbnailProvider: QLThumbnailProvider {
|
||||||
override func provideThumbnail(for request: QLFileThumbnailRequest, _ handler: @escaping (QLThumbnailReply?, Error?) -> Void) {
|
override func provideThumbnail(for request: QLFileThumbnailRequest, _ handler: @escaping (QLThumbnailReply?, Error?) -> Void) {
|
||||||
let fc: NSFileCoordinator = NSFileCoordinator()
|
|
||||||
let intent: NSFileAccessIntent = NSFileAccessIntent.readingIntent(with: request.fileURL)
|
|
||||||
fc.coordinate(with: [intent], queue: .main) { (err) in
|
|
||||||
if err == nil {
|
|
||||||
do {
|
do {
|
||||||
guard let archive = Archive(data: try Data(contentsOf: intent.url), accessMode: Archive.AccessMode.read) else {
|
guard let archive = Archive(data: try Data(contentsOf: request.fileURL), accessMode: Archive.AccessMode.read) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,13 +50,9 @@ class ThumbnailProvider: QLThumbnailProvider {
|
||||||
|
|
||||||
handler(reply, nil)
|
handler(reply, nil)
|
||||||
} catch {
|
} catch {
|
||||||
NSLog("Could not load file \(intent.url.lastPathComponent) to preview it")
|
NSLog("Could not access file \(request.fileURL.lastPathComponent) to preview it")
|
||||||
handler(nil, nil)
|
handler(nil, nil)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
NSLog("Could not find file \(intent.url.lastPathComponent) to preview it")
|
|
||||||
handler(nil, nil)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue