From e0e3919d6919b16f86605b211911a7705d31cdd2 Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Wed, 11 Jan 2023 19:56:52 +0100 Subject: [PATCH] Fix config bug --- Sources/App/Config.swift | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Sources/App/Config.swift b/Sources/App/Config.swift index 61ee309..7ee358f 100644 --- a/Sources/App/Config.swift +++ b/Sources/App/Config.swift @@ -35,7 +35,7 @@ extension Config { self.init(loadAt: configFileUrl) } else { self.init(standardIn: directory) - + write(to: configFileUrl) } } @@ -53,14 +53,15 @@ extension Config { private init(standardIn directory: URL) { let defaultLogPath = directory.appendingPathComponent("logs").path self.init(port: 8000, maxBodySize: "2mb", logPath: defaultLogPath, serveFiles: true, writers: []) - - let configFileUrl = Config.file(in: directory) + } + + private func write(to url: URL) { do { let configData = try JSONEncoder().encode(self) - try configData.write(to: configFileUrl) - print("Default configuration written at \(configFileUrl.path)") + try configData.write(to: url) + print("Configuration written at \(url.path)") } catch { - print("Failed to write default configuration to \(configFileUrl.path)") + print("Failed to write default configuration to \(url.path)") } } }