Fix security-scoped URL access balancing

This commit is contained in:
世界
2026-02-04 22:32:02 +08:00
parent 20e22b691a
commit 4ae421cd04
8 changed files with 77 additions and 32 deletions
+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)
}