Fix theme-importing — use startAccessingSecurityScopedResource and stopAccessingSecurityScopedResource, which appear to be required now.

This commit is contained in:
Brent Simmons
2024-12-31 21:15:51 -08:00
parent f2e12f6b2e
commit b0b5ad018c
5 changed files with 57 additions and 38 deletions

View File

@@ -117,11 +117,18 @@ extension ArticleThemesTableViewController: UIDocumentPickerDelegate {
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
guard let url = urls.first else { return }
do {
try ArticleThemeImporter.importTheme(controller: self, filename: url.standardizedFileURL.path)
} catch {
NotificationCenter.default.post(name: .didFailToImportThemeWithError, object: nil, userInfo: ["error": error])
if url.startAccessingSecurityScopedResource() {
defer {
url.stopAccessingSecurityScopedResource()
}
do {
try ArticleThemeImporter.importTheme(controller: self, url: url)
} catch {
NotificationCenter.default.post(name: .didFailToImportThemeWithError, object: nil, userInfo: ["error": error])
}
}
}
}