From e3eac6a9fe4a25d9d8ff3948e5cf7235ef838777 Mon Sep 17 00:00:00 2001 From: david-swift Date: Tue, 8 Oct 2024 15:27:37 +0200 Subject: [PATCH] Create directory before establishing connection --- Sources/State.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sources/State.swift b/Sources/State.swift index d3490ea..4ff2343 100644 --- a/Sources/State.swift +++ b/Sources/State.swift @@ -73,6 +73,12 @@ public enum DatabaseInformation { if let privateConnection { return privateConnection } + if let url = URL(string: path) { + try? FileManager.default.createDirectory( + at: url.deletingLastPathComponent(), + withIntermediateDirectories: true + ) + } let connection = try? Connection(path) privateConnection = connection _ = try? connection?.run(table.create { table in