Skip to content

Commit

Permalink
Open database read-only by default
Browse files Browse the repository at this point in the history
  • Loading branch information
christophhagen committed Mar 22, 2024
1 parent 4684ddf commit cd077d0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Sources/HKDatabase/Database/HKDatabaseStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ public final class HKDatabaseStore {

/**
Open a Health database at the given url.
- Parameter fileUrl: The url to the sqlite file
- Parameter readOnly: Indicate if the database should be writable
*/
public convenience init(fileUrl: URL) throws {
let database = try Connection(fileUrl.path)
public convenience init(fileUrl: URL, readOnly: Bool = true) throws {
let database = try Connection(fileUrl.path, readonly: readOnly)
self.init(fileUrl: fileUrl, database: database)
}

Expand Down
7 changes: 6 additions & 1 deletion Sources/HKDatabase/Database/HealthDatabase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ public final class HealthDatabase {
self.store = store
}

public init(fileUrl: URL) throws {
/**
Open a health database.
- Parameter fileUrl: The url to the sqlite file
- Parameter readOnly: Indicate if the database should be writable
*/
public init(fileUrl: URL, readOnly: Bool = true) throws {
self.store = try .init(fileUrl: fileUrl)
}

Expand Down

0 comments on commit cd077d0

Please sign in to comment.