Skip to content

Commit

Permalink
ensure stopAccessing called
Browse files Browse the repository at this point in the history
  • Loading branch information
EricBAndrews committed Oct 15, 2024
1 parent ce6fe08 commit dc1366e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ struct ImportExportSettingsPage: View {
isPresented: $importingSettingsFile,
allowedContentTypes: [.json]
) { result in
var fileUrl: URL?
do {
let fileUrl = try result.get()
if fileUrl.startAccessingSecurityScopedResource() {
fileUrl = try result.get()
if let fileUrl, fileUrl.startAccessingSecurityScopedResource() {
let fileData = try Data(contentsOf: fileUrl, options: .mappedIfSafe)
fileUrl.stopAccessingSecurityScopedResource()

Expand All @@ -47,6 +48,7 @@ struct ImportExportSettingsPage: View {
ToastModel.main.add(.failure("Failed to Import Settings"))
}
} catch {
fileUrl?.stopAccessingSecurityScopedResource()
handleError(error)
}
}
Expand Down
3 changes: 3 additions & 0 deletions Mlem/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,9 @@
},
"Failed to delete post!" : {

},
"Failed to Import Settings" : {

},
"Failed to lock post" : {

Expand Down

0 comments on commit dc1366e

Please sign in to comment.