Remove creating subpath for file database
This commit is contained in:
@@ -48,8 +48,6 @@ public final class Connection {
|
||||
/// Initializes a new connection to an SQLite database.
|
||||
///
|
||||
/// Opens a connection to the database at the specified `location` using the given `options`.
|
||||
/// If the location represents a file path, this method ensures that the parent directory
|
||||
/// exists, creating intermediate directories if needed.
|
||||
///
|
||||
/// ### Example
|
||||
///
|
||||
@@ -73,15 +71,7 @@ public final class Connection {
|
||||
///
|
||||
/// - Throws: ``SQLiteError`` if the connection cannot be opened or initialized due to
|
||||
/// SQLite-related issues such as invalid path, missing permissions, or corruption.
|
||||
/// - Throws: An error if directory creation fails for file-based database locations.
|
||||
public init(location: Location, options: Options) throws {
|
||||
if case let Location.file(path) = location, !path.isEmpty {
|
||||
try FileManager.default.createDirectory(
|
||||
at: URL(fileURLWithPath: path).deletingLastPathComponent(),
|
||||
withIntermediateDirectories: true
|
||||
)
|
||||
}
|
||||
|
||||
public init(location: Location, options: Options) throws(SQLiteError) {
|
||||
var connection: OpaquePointer! = nil
|
||||
let status = sqlite3_open_v2(location.path, &connection, options.rawValue, nil)
|
||||
|
||||
@@ -121,8 +111,7 @@ public final class Connection {
|
||||
///
|
||||
/// - Throws: ``SQLiteError`` if the connection cannot be opened due to SQLite-level errors,
|
||||
/// invalid path, missing permissions, or corruption.
|
||||
/// - Throws: An error if the required directory structure cannot be created.
|
||||
public convenience init(path: String, options: Options) throws {
|
||||
public convenience init(path: String, options: Options) throws(SQLiteError) {
|
||||
try self.init(location: .file(path: path), options: options)
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,8 @@ SQLite messages verbatim.
|
||||
Most DataLiteCore APIs are annotated as `throws(SQLiteError)`, meaning they only throw SQLiteError
|
||||
instances.
|
||||
|
||||
Only APIs that touch the file system or execute arbitrary user code may throw other error
|
||||
types — for example, ``Connection/init(location:options:)`` when creating directories for on-disk
|
||||
databases.
|
||||
Only APIs that execute arbitrary user code or integrate with external systems may surface other
|
||||
error types. Consult the documentation on each API for specific details.
|
||||
|
||||
```swift
|
||||
do {
|
||||
|
||||
Reference in New Issue
Block a user