Skip to content

Commit

Permalink
Fix #475. (#476)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgoedjen authored Jul 23, 2023
1 parent df10fa3 commit 1d4ef12
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ public class PublicKeyFileStoreController {
logger.log("Writing public keys to disk")
if clear {
let validPaths = Set(secrets.map { publicKeyPath(for: $0) }).union(Set(secrets.map { sshCertificatePath(for: $0) }))
let untracked = Set(try FileManager.default.contentsOfDirectory(atPath: directory)
.map { "\(directory)/\($0)" })
let contentsOfDirectory = (try? FileManager.default.contentsOfDirectory(atPath: directory)) ?? []
let fullPathContents = contentsOfDirectory.map { "\(directory)/\($0)" }

let untracked = Set(fullPathContents)
.subtracting(validPaths)
for path in untracked {
try? FileManager.default.removeItem(at: URL(fileURLWithPath: path))
Expand Down

0 comments on commit 1d4ef12

Please sign in to comment.