Allow custom data directory
This commit is contained in:
@ -20,6 +20,15 @@ struct Config: Codable {
|
||||
/// Authentication tokens for remotes allowed to write
|
||||
let writers: [String]
|
||||
|
||||
let dataDirectory: String?
|
||||
|
||||
func customDataDirectory(or publicDirectory: String) -> URL {
|
||||
guard let dataDirectory else {
|
||||
return URL(fileURLWithPath: publicDirectory)
|
||||
}
|
||||
return URL(fileURLWithPath: dataDirectory)
|
||||
}
|
||||
|
||||
func logURL(possiblyRelativeTo resourcesDirectory: URL) -> URL {
|
||||
guard let logPath else {
|
||||
return resourcesDirectory.appendingPathComponent("logs")
|
||||
|
@ -31,7 +31,8 @@ func configure(_ app: Application) async throws {
|
||||
app.http.server.configuration.port = config.port
|
||||
app.routes.defaultMaxBodySize = .init(stringLiteral: config.maxBodySize)
|
||||
|
||||
server = CapServer(in: URL(fileURLWithPath: publicDirectory))
|
||||
let dataDirectory = config.customDataDirectory(or: publicDirectory)
|
||||
server = CapServer(in: dataDirectory)
|
||||
|
||||
provider = .init(observer: monitor, accessManager: config.writers)
|
||||
provider.asyncScheduler = asyncScheduler
|
||||
|
Reference in New Issue
Block a user