support reading several key IDs in .gpg-id files

This commit is contained in:
Lysann Tranvouez 2026-03-11 22:57:51 +01:00
parent 566b7253f5
commit 77f85ccdd1
8 changed files with 19 additions and 9 deletions

View file

@ -410,7 +410,7 @@ public class PasswordStore {
}
if Defaults.isEnableGPGIDOn {
let encryptedDataPath = password.fileURL(in: storeURL)
return [findGPGID(from: encryptedDataPath)]
return findGPGIDs(from: encryptedDataPath)
}
return []
}()
@ -461,7 +461,7 @@ extension PasswordStore {
}
}
func findGPGID(from url: URL) -> String {
func findGPGIDs(from url: URL) -> [String] {
var path = url
while !FileManager.default.fileExists(atPath: path.appendingPathComponent(".gpg-id").path),
path.path != "file:///" {
@ -469,5 +469,9 @@ func findGPGID(from url: URL) -> String {
}
path = path.appendingPathComponent(".gpg-id")
return (try? String(contentsOf: path))?.trimmed ?? ""
let allKeysSeparatedByNewline = (try? String(contentsOf: path)) ?? ""
return allKeysSeparatedByNewline
.split(separator: "\n")
.map { String($0).trimmed }
.filter { !$0.isEmpty }
}