diff --git a/Resources/TileServer/Empty.mbtiles b/Resources/TileServer/Empty.mbtiles new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Resources/TileServer/Empty.mbtiles @@ -0,0 +1 @@ + diff --git a/Sources/SwiftTileserverCache/Controller/StylesController.swift b/Sources/SwiftTileserverCache/Controller/StylesController.swift index 021e586..d40aee6 100644 --- a/Sources/SwiftTileserverCache/Controller/StylesController.swift +++ b/Sources/SwiftTileserverCache/Controller/StylesController.swift @@ -61,7 +61,7 @@ internal class StylesController { } }) } - + internal func analyse(request: Request, id: String) -> EventLoopFuture { return analyseUsage(request: request, id: id).flatMap({ usage in return self.analyseAvilableIcons(request: request, id: id).flatMapThrowing({ icons in @@ -73,8 +73,12 @@ internal class StylesController { missingIcons: missingIcons ) }) + }).recover({ _ in + return .init( + missingFonts: ["error loading style"], + missingIcons: ["error loading style"] + ) }) - } internal func addExternal(request: Request) throws -> EventLoopFuture { diff --git a/Sources/SwiftTileserverCache/Misc/CacheCleaner.swift b/Sources/SwiftTileserverCache/Misc/CacheCleaner.swift index dd78ab5..6f1d2b3 100644 --- a/Sources/SwiftTileserverCache/Misc/CacheCleaner.swift +++ b/Sources/SwiftTileserverCache/Misc/CacheCleaner.swift @@ -22,7 +22,7 @@ public class CacheCleaner { let thread = DispatchQueue(label: "CacheCleaner-\(folder)") try? FileManager.default.createDirectory(atPath: folder, withIntermediateDirectories: true) if maxAgeMinutes != nil && clearDelaySeconds != nil { - self.logger.notice("Starting CacheCleaner for \(folder) with maxAgeMinutes: \(maxAgeMinutes) and clearDelaySeconds: \(clearDelaySeconds)") + self.logger.notice("Starting CacheCleaner for \(folder) with maxAgeMinutes: \(maxAgeMinutes!) and clearDelaySeconds: \(clearDelaySeconds!)") thread.async { while true { self.runOnce() diff --git a/Sources/SwiftTileserverCache/tileserver.swift b/Sources/SwiftTileserverCache/tileserver.swift index f0774a3..df0fa74 100644 --- a/Sources/SwiftTileserverCache/tileserver.swift +++ b/Sources/SwiftTileserverCache/tileserver.swift @@ -2,7 +2,8 @@ import Vapor public func tileserver(_ app: Application) throws { if !FileManager.default.fileExists(atPath: "TileServer/config.json") { - app.logger.info("Copying default TileServer config.json") + app.logger.info("Copying default TileServer configuration") try FileManager.default.copyItem(atPath: "Resources/TileServer/config.json", toPath: "TileServer/config.json") + try FileManager.default.copyItem(atPath: "Resources/TileServer/Empty.mbtiles", toPath: "TileServer/Datasets/Combined.mbtiles") } }