Fix security-scoped URL access balancing

This commit is contained in:
世界 committed 2026-02-04 22:32:02 +08:00
1 parent 20e22b691a
commit 4ae421cd04
8 files changed
+77 -32

No files matched your search

+3 -3
View File
@@ -58,9 +58,9 @@ public class MainViewModel: BaseViewModel {
private func importURLProfile(_ url: URL) async {
do {
_ = url.startAccessingSecurityScopedResource()
importProfile = try await .from(readURL(url))
url.stopAccessingSecurityScopedResource()
importProfile = try await url.withSecurityScopedAccess {
try await .from(readURL(url))
}
} catch {
alert = AlertState(error: error)
}