Skip to content

Commit

Permalink
fix: only clear broken cache images
Browse files Browse the repository at this point in the history
  • Loading branch information
123FLO321 committed Apr 25, 2023
1 parent 9c478bb commit a61e714
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Sources/SwiftTileserverCache/Misc/ImageUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,11 @@ public class ImageUtils {
}

private static func removeImages(request: Request, paths: [String]) -> Void {
request.logger.info("Clearing \(paths.count) potentially broken images")
try? escapedShellOut(to: "rm", arguments: ["-f"] + paths)
let cachePaths = paths.filter { $0.starts(with: "Cache/") }
if cachePaths.count > 0 {
request.logger.info("Clearing \(cachePaths.count) potentially broken images")
try? escapedShellOut(to: "rm", arguments: ["-f"] + cachePaths)
}
}

}

0 comments on commit a61e714

Please sign in to comment.