Skip to content

Commit

Permalink
Merge pull request #128 from moneymanagerex/txn
Browse files Browse the repository at this point in the history
Bundle resource is not scoped and refine statement to lead sample database
  • Loading branch information
guanlisheng authored Oct 8, 2024
2 parents 8154ef3 + 7c2232d commit f409ce4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion MMEX/App/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ struct ContentView: View {
.controlSize(.large)

Button(action: { isNewDocumentPickerPresented = true; isSampleDocument = true }) {
Label("Use Sample Database", systemImage: "doc.text.fill")
Label("Create and Use Sample Database", systemImage: "doc.text.fill")
}
.buttonStyle(.bordered)
.controlSize(.large)
Expand Down
15 changes: 4 additions & 11 deletions MMEX/App/EnvironmentManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,15 @@ extension EnvironmentManager {
openDatabase(at: url, isNew: true)
guard let db else { return }

guard let tables = Bundle.main.url(forResource: "tables.sql", withExtension: "") else {
guard let tables = Bundle.main.url(forResource: "tables", withExtension: "sql") else {
log.error("Cannot find tables.sql")
closeDatabase()
return
}

if tables.startAccessingSecurityScopedResource() {
defer { tables.stopAccessingSecurityScopedResource() }
let repository = Repository(db)
repository.setUserVersion (19)
guard repository.execute(url: tables) else {
closeDatabase()
return
}
} else {
log.error("Failed to access security-scoped resource: \(tables.path)")
let repository = Repository(db)
repository.setUserVersion (19)
guard repository.execute(url: tables) else {
closeDatabase()
return
}
Expand Down

0 comments on commit f409ce4

Please sign in to comment.